Skip to content

fix(subconscious): route text-only tasks through cloud when local AI disabled#1565

Merged
senamakel merged 8 commits into
tinyhumansai:mainfrom
PranavAgarkar07:fix/subconscious-intelligence-local-ai-1374
May 13, 2026
Merged

fix(subconscious): route text-only tasks through cloud when local AI disabled#1565
senamakel merged 8 commits into
tinyhumansai:mainfrom
PranavAgarkar07:fix/subconscious-intelligence-local-ai-1374

Conversation

@PranavAgarkar07
Copy link
Copy Markdown
Contributor

@PranavAgarkar07 PranavAgarkar07 commented May 12, 2026

Summary

When local AI is disabled, text-only subconscious tasks (summarize, check, monitor, review, analyze, extract, classify) would fail every tick with local_ai.usage.subconscious not enabled (no cloud fallback configured), filling the activity log with repeated Execution failed entries.

Changes

src/openhuman/subconscious/executor.rs — Modified the text-only task routing in execute_task():

  • If local AI is enabled (use_local_for_subconscious() returns true): use the local model as before
  • If local AI is disabled: route through execute_with_agent_analysis() (cloud agentic-v1), which was already working for read-only tasks needing deeper reasoning

This is the exact fix the TODO at line 117 was asking for: "wire a cloud fallback here when use_local_for_subconscious is false."

Impact

  • No more repeated Execution failed entries in the activity log when local AI is disabled
  • Text-only tasks still get executed via cloud
  • Existing behavior for tool-needing tasks and deep-analysis tasks unchanged

Partially addresses #1374

Summary by CodeRabbit

  • Bug Fixes

    • Text-only tasks reliably fall back to analysis when local processing is disabled and no longer escalate incorrectly.
  • Improvements

    • Task routing consistently selects local processing, cloud analysis, or full agent execution based on intent and runtime settings.
    • Analysis that recommends actions is surfaced as an explicit "unapproved write" outcome; completed runs report whether tools were used.
    • Improved runtime diagnostics for execution outcomes.
  • Tests

    • Added tests verifying routing with local-enabled vs local-disabled configurations.

Review Change Stack

…disabled

When local AI is disabled, text-only subconscious tasks would
fail every tick with 'local_ai.usage.subconscious not enabled'.
Route them through the cloud agentic analysis path instead.

Before: text-only tasks → execute_with_local_model() → Err
After:  text-only tasks → local AI check → local (if enabled)
                                              → cloud agent_analysis (fallback)

Closes tinyhumansai#1374
@PranavAgarkar07 PranavAgarkar07 requested a review from a team May 12, 2026 15:10
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

execute_task loads Config and routes tasks: write-intent → full agent loop; needs-agent → analysis-only; text-only → local model when enabled or cloud analysis otherwise, with cloud analysis mapping "RECOMMENDED ACTION:" to UnapprovedWrite when applicable.

Changes

Execution routing, agent delegates, and tests

Layer / File(s) Summary
Config-driven routing and approved-write entry
src/openhuman/subconscious/executor.rs
execute_task and execute_approved_write now load Config up front and route write-intent tasks to execute_with_agent_full(&mut config, ...). Added #[derive(Debug)] to ExecutionOutcome.
Agent helper signature changes and delegation
src/openhuman/subconscious/executor.rs
execute_with_agent_full and execute_with_agent_analysis now accept &mut Config and delegate to agent_chat_with_retry instead of loading Config themselves; the needs_agent() branch uses the preloaded config.
Local-model helper signature and routing tests
src/openhuman/subconscious/executor.rs, tests
execute_with_local_model now takes &Config and assumes the caller checked use_local_for_subconscious(). Tests add an env-var guard and temp workspace/config writer and verify routing to cloud vs local depending on local_ai_enabled. Cloud analysis still inspects "RECOMMENDED ACTION:" and may return UnapprovedWrite or Completed { used_tools: false }.

Sequence Diagram

sequenceDiagram
  participant Client as execute_task
  participant Config
  participant Local as execute_with_local_model
  participant Analysis as execute_with_agent_analysis
  participant Full as execute_with_agent_full
  Client->>Config: load_or_init()
  Config-->>Client: Config (mutable)
  alt write-intent
    Client->>Full: execute_with_agent_full(&mut Config, task)
    Full-->>Client: ExecutionOutcome
  else needs_agent
    Client->>Analysis: execute_with_agent_analysis(&mut Config, task)
    Analysis-->>Client: analysis output
  else text-only
    Client->>Config: check local_ai.use_local_for_subconscious()
    alt local enabled
      Client->>Local: execute_with_local_model(&Config, task)
      Local-->>Client: ExecutionOutcome
    else local disabled
      Client->>Analysis: execute_with_agent_analysis(&mut Config, task)
      Analysis-->>Client: analysis output (RECOMMENDED ACTION handling)
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 I read the config, sharp and neat,
If local wakes, I skip the fleet,
Else cloud will speak with dotted line,
"RECOMMENDED ACTION:" marks the sign,
I hop the path the code will meet.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: routing text-only tasks to cloud (execute_with_agent_analysis) when local AI is disabled, which directly addresses the core problem of execution failures when local AI is off.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/openhuman/subconscious/executor.rs (2)

145-145: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove stale TODO comment.

The TODO about wiring a cloud fallback has been completed — the caller (execute_task) now implements the cloud fallback at lines 93-114. This comment is now stale and should be removed to avoid confusion.

🧹 Proposed fix
-/// TODO: wire a cloud fallback here when use_local_for_subconscious is false.
 async fn execute_with_local_model(
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openhuman/subconscious/executor.rs` at line 145, Remove the stale TODO
comment in src/openhuman/subconscious/executor.rs that says "TODO: wire a cloud
fallback here when use_local_for_subconscious is false" because the cloud
fallback is already implemented by the caller in execute_task; simply delete
that comment to avoid confusion and keep the file clean (look for the TODO near
the executor module where execute_task is used).

155-169: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Unreachable check — dead code.

Since the caller (execute_task line 79) now checks use_local_for_subconscious() before calling execute_with_local_model, this check at line 155 will always pass and the error path at lines 161-168 is unreachable dead code. Additionally, the error message "no cloud fallback configured" is now inaccurate because the cloud fallback exists in the caller.

Remove this check or update the function's contract. If execute_with_local_model is intended to be a private function only called from execute_task, the check is redundant. If it's meant to be called from multiple places, consider whether those call sites also implement the routing logic.

🧹 Proposed fix: Remove unreachable code
 async fn execute_with_local_model(
     task: &SubconsciousTask,
     situation_report: &str,
     identity_context: &str,
 ) -> Result<String, String> {
     let config = crate::openhuman::config::Config::load_or_init()
         .await
         .map_err(|e| format!("config load: {e}"))?;
 
-    if !config.local_ai.use_local_for_subconscious() {
-        // Fail fast rather than returning Ok("") — upstream code uses an
-        // empty string as a normal "task ran but produced no output"
-        // signal, so a silent skip would mask a disabled subsystem as a
-        // completed action. Surface the gate state so callers can
-        // distinguish "skipped" from "succeeded with empty output".
-        tracing::info!(
-            "[subconscious:executor] local_ai.usage.subconscious not enabled — \
-             refusing to execute task '{}' (no cloud fallback configured)",
-            task.title
-        );
-        return Err(
-            "local_ai.usage.subconscious not enabled (no cloud fallback configured)".to_string(),
-        );
-    }
-
     let prompt_text = prompt::build_text_execution_prompt(task, situation_report, identity_context);

Note: This assumes you also implement the fix from the previous comment to pass config to avoid redundant loading.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openhuman/subconscious/executor.rs` around lines 155 - 169, The
conditional guard in execute_with_local_model that checks
config.local_ai.use_local_for_subconscious() and returns an error is now
dead/unreachable because execute_task already performs that check; remove this
redundant if-block and its Err return (or alternatively make
execute_with_local_model private and document its precondition to require the
caller has validated use_local_for_subconscious()), and ensure callers supply
the config (as per the earlier change) so you don't re-load config inside
execute_with_local_model.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/openhuman/subconscious/executor.rs`:
- Around line 75-92: The code redundantly loads Config and re-checks
use_local_for_subconscious() inside execute_with_local_model; refactor by
changing execute_with_local_model to accept a &crate::openhuman::config::Config
(or &Config) and the existing task, situation_report, identity_context
parameters, then remove the Config::load_or_init call and the
use_local_for_subconscious() check from inside execute_with_local_model; update
the caller that currently calls execute_with_local_model(...) to pass the
already-loaded config from Config::load_or_init(), ensuring only the caller
performs routing based on config::use_local_for_subconscious() and the callee
only performs local execution logic.

---

Outside diff comments:
In `@src/openhuman/subconscious/executor.rs`:
- Line 145: Remove the stale TODO comment in
src/openhuman/subconscious/executor.rs that says "TODO: wire a cloud fallback
here when use_local_for_subconscious is false" because the cloud fallback is
already implemented by the caller in execute_task; simply delete that comment to
avoid confusion and keep the file clean (look for the TODO near the executor
module where execute_task is used).
- Around line 155-169: The conditional guard in execute_with_local_model that
checks config.local_ai.use_local_for_subconscious() and returns an error is now
dead/unreachable because execute_task already performs that check; remove this
redundant if-block and its Err return (or alternatively make
execute_with_local_model private and document its precondition to require the
caller has validated use_local_for_subconscious()), and ensure callers supply
the config (as per the earlier change) so you don't re-load config inside
execute_with_local_model.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3edefad9-03b5-4c96-81f6-6579478a822d

📥 Commits

Reviewing files that changed from the base of the PR and between 15c7442 and dc598bd.

📒 Files selected for processing (1)
  • src/openhuman/subconscious/executor.rs

Comment thread src/openhuman/subconscious/executor.rs Outdated
execute_with_local_model was reloading Config and re-checking
use_local_for_subconscious(), duplicating work already done by
the caller in execute_task(). Pass the already-loaded Config as
a parameter instead.

The gate check remains in the caller (execute_task) which routes
to the cloud fallback when local AI is disabled.
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 12, 2026
Copy link
Copy Markdown
Contributor

@graycyrus graycyrus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — 2 actionable findings, 1 nitpick, 2 questions

The core fix is correct and valuable — cloud fallback for text-only tasks when local AI is disabled. Second commit cleaning up the config threading is good. See inline comments for details.

Verified / looks good:

  • No bare .unwrap(), proper [subconscious:executor] log prefix, no PII in logs
  • UnapprovedWrite handling mirrors existing needs_agent branch exactly
  • execute_with_local_model config threading is correct
  • No new standalone .rs files at src/openhuman/ root

Comment thread src/openhuman/subconscious/executor.rs Outdated
task.title
);
let output =
execute_with_agent_analysis(task, situation_report, identity_context).await?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[major] Double config load on the cloud fallback path

execute_task loads Config at lines 75–77, then calls execute_with_agent_analysis here, which loads Config again internally. This is the same class of issue CodeRabbit caught on the local path (and you fixed in commit 2) — but on the cloud path.

Every cloud-fallback tick pays two async config reads, and there’s a TOCTOU window: if config changes between the two loads, the branch decision at line 79 was made with config_A but the cloud call runs with config_B.

Fix is the same pattern from commit 2 — pass &mut Config to execute_with_agent_analysis:

async fn execute_with_agent_analysis(
    config: &mut crate::openhuman::config::Config,
    task: &SubconsciousTask,
    situation_report: &str,
    identity_context: &str,
) -> Result<String, String> {
    let prompt_text = prompt::build_analysis_only_prompt(task, situation_report, identity_context);
    agent_chat_with_retry(config, &prompt_text).await
}

Note: the needs_agent branch (line 56) also calls execute_with_agent_analysis without a pre-loaded config — that call site would need updating too.

ExecutionOutcome::Completed(ExecutionResult {
.map_err(|e| format!("config load: {e}"))?;

if config.local_ai.use_local_for_subconscious() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[major] No tests for the new routing branch

The if config.local_ai.use_local_for_subconscious() decision here (lines 79–114) is completely untested. The existing test suite covers needs_tools, needs_agent, and extract_recommended_action — all pure functions — but nothing exercises this new conditional routing.

Issue #1374 criterion 6 explicitly requires regression safety for the unavailable-provider and enabled-provider paths, and criterion 7 requires ≥ 80% diff coverage (enforced by the CI coverage gate).

Minimum bar: two #[tokio::test] cases — one with use_local_for_subconscious() = false asserting cloud routing, one with true asserting local routing. If Config::load_or_init is hard to mock at the unit level, an integration test in tests/ exercising the RPC method with the mock backend would also work.

Comment thread src/openhuman/subconscious/executor.rs Outdated
task.title
);
execute_with_local_model(task, situation_report, identity_context)
// Simple text-only task. Use local model if available, otherwise
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Comment says "if available" but the actual gate is use_local_for_subconscious() — a deliberate config flag, not availability. Tighter wording:

// Simple text-only task. Use local model if configured for subconscious
// tasks, otherwise fall back to the cloud agentic analysis path.

Comment thread src/openhuman/subconscious/executor.rs Outdated
execute_with_agent_analysis(task, situation_report, identity_context).await?;
let duration_ms = started.elapsed().as_millis() as u64;

if let Some(recommendation) = extract_recommended_action(&output) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question] When the cloud-fallback path returns UnapprovedWrite, the recommendation surfaces in the escalation UI. For a task the user defined as text-only (passive verb like "Summarize emails"), is it intentional that it can produce a write escalation via RECOMMENDED ACTION:? The needs_agent branch already does this, but those tasks are explicitly flagged as complex. For a simple text-only task hitting this path, the UX consequence seems surprising. Worth documenting the intent even if the behavior is correct.

duration_ms: started.elapsed().as_millis() as u64,
})
})
} else {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question] Issue #1374 criteria 2 (both-unavailable UI state), 3 (evaluation gating), and 4 (recovery without restart) are not addressed by this PR, but the PR closes #1374. Are these tracked as follow-ups, or intentionally descoped? If descoped, consider partially closing the issue or filing a follow-up so the issue tracker reflects what’s actually done.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 12, 2026
@PranavAgarkar07 PranavAgarkar07 requested a review from graycyrus May 12, 2026 17:56
Copy link
Copy Markdown
Contributor

@graycyrus graycyrus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — 2 blockers, 3 suggestions

The core fix is correct and valuable — cloud fallback for text-only tasks when local AI is disabled. Config-hoisting refactor is clean. But two questions from the previous review remain unanswered (findings 1 & 2 below are blocking), plus three non-blocking suggestions.

Verified / looks good:

  • Config hoisting correct — single load, threaded to all helpers
  • &Config (immutable) for local path, &mut Config for agent paths — matches downstream signatures
  • EnvVarGuard + TEST_ENV_LOCK consistent with existing config tests
  • No bare .unwrap(), proper [subconscious:executor] prefix, no PII in logs
  • File stays well under 500 lines, no new standalone .rs at root

Comment thread src/openhuman/subconscious/executor.rs Outdated
execute_with_agent_analysis(&mut config, task, situation_report, identity_context).await?;
let duration_ms = started.elapsed().as_millis() as u64;

if let Some(recommendation) = extract_recommended_action(&output) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[major] UnapprovedWrite from text-only tasks via cloud fallback — unanswered question

A passive task like "Summarize emails" can now produce a write escalation if the cloud model includes RECOMMENDED ACTION: in its output. This silently changes the task's contract from read-only to write-capable — the needs_tools gate was supposed to be the write-intent signal, and this path bypasses it.

Two options:

  1. Suppress — force Completed on the text-only cloud-fallback path (never produce UnapprovedWrite for passive tasks)
  2. Keep and document — add a comment explaining that cloud analysis can surface recommendations even from read-only tasks, and that the approval gate still applies

Either is fine but the PR needs an explicit decision. This was flagged in the previous review and remains unanswered.

duration_ms: started.elapsed().as_millis() as u64,
})
})
} else {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[major] PR closes #1374 but only criterion 1 of 4 is addressed

Issue #1374 acceptance criteria:

  1. ✅ Repro gone — cloud fallback routing (this PR)
  2. ❌ Unavailable-state UI — no UI changes
  3. ❌ Evaluation gating — tasks still scheduled when no provider available
  4. ❌ Recovery without restart — not addressed

`Closes #1374` in the PR body will auto-close the issue on merge, silently dropping criteria 2–4. Either:

);
let output =
execute_with_agent_analysis(&mut config, task, situation_report, identity_context).await?;
let duration_ms = started.elapsed().as_millis() as u64;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] No exit/completion logging on cloud-fallback path

Entry logs at `info!` (line 84) but there's no log on completion, on the `UnapprovedWrite` branch, or on error from `execute_with_agent_analysis`. CLAUDE.md requires entry/exit logging on new flows.

Suggested additions after the `let output = ...` line:
```rust
debug!(
"[subconscious:executor] text task cloud fallback complete: {} — duration_ms={}",
task.title, duration_ms
);
```

And on the `UnapprovedWrite` arm:
```rust
info!(
"[subconscious:executor] text task cloud fallback produced write recommendation: {}",
task.title
);
```

ExecutionOutcome::Completed(ExecutionResult {
// Simple text-only task. Use local model if configured for subconscious
// tasks, otherwise fall back to the cloud agentic analysis path.
if config.local_ai.use_local_for_subconscious() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] Test assertions too loose to verify actual routing

Both routing tests assert `is_err()` + error string contains `"agent execution"` or `"local model"`. If routing logic inverts (e.g., the `if` condition is flipped), both could still pass because connection failures produce similar error shapes.

Stronger approach: use distinct error-prefix strings in `execute_with_local_model` vs `execute_with_agent_analysis` so the test can assert the specific path, not just that something failed. Alternatively, a `cfg(test)` counter or mock seam.

.map_err(|e| format!("config load: {e}"))?;
let output = execute_with_agent_full(&mut config, task, situation_report, identity_context).await?;
Ok(ExecutionResult {
output,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] `execute_approved_write` loads config independently — TOCTOU window

This is a separate entry point so an independent `Config::load_or_init()` is reasonable. But it creates a TOCTOU window: the task was originally routed under config_A in `execute_task`, and now the approved write executes under config_B. If `use_local_for_subconscious()` toggled between the two calls, the approval was made under different assumptions.

Low risk, but worth a one-line comment documenting that this is an intentional independent load.

…s review feedback

Graycyrus review findings addressed:
- [blocker] Suppress UnapprovedWrite on text-only cloud-fallback path
  — passive tasks never escalate, preserves write-intent gate contract
- [blocker] PR body updated: Closes tinyhumansai#1374 → Partially addresses tinyhumansai#1374
- [minor] Add debug! exit logging on cloud-fallback completion path
- [minor] Distinct error prefix for cloud fallback routing tests
- [nitpick] TOCTOU comment on execute_approved_write
- [fix] Add #[derive(Debug)] to ExecutionOutcome for test unwrap_err()
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/openhuman/subconscious/executor.rs`:
- Around line 405-443: The tests
execute_task_routes_to_cloud_when_local_disabled and
execute_task_routes_to_local_when_local_enabled are relying on real backend
failures; instead add a test seam so execute_task's backend calls can be faked:
modify execute_task to accept an optional dependency/injectable function or
trait (or use a cfg/test-only feature) for the two backends
execute_with_local_model and execute_with_agent_analysis, then in the tests
replace those with deterministic fakes that return distinct sentinel errors or
results so the assertions verify which path was chosen; update the tests to
inject the fake implementations (referencing execute_task,
execute_with_local_model, execute_with_agent_analysis, and the two test
functions) and assert against the sentinel values rather than expecting
incidental real-provider errors.
- Around line 80-109: The logs in the executor paths are printing user-authored
PII via task.title; update the logging calls around execute_with_local_model and
execute_with_agent_analysis to avoid emitting task.title and instead log task.id
and route metadata (e.g., local vs cloud fallback) as structured fields, e.g.
change the debug/info messages that reference task.title to include task.id and
a stable prefix like "[subconscious:executor]" plus the route ("local" or
"cloud-fallback"), and keep duration_ms and used_tools as before; ensure any
other debug line that currently interpolates task.title is similarly switched to
task.id to prevent PII leakage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 38d78e37-c9b8-4e2b-809d-0532b758d5e0

📥 Commits

Reviewing files that changed from the base of the PR and between e57a05b and ff959aa.

📒 Files selected for processing (1)
  • src/openhuman/subconscious/executor.rs

Comment thread src/openhuman/subconscious/executor.rs Outdated
Comment thread src/openhuman/subconscious/executor.rs
…t mocks

- Replace task.title with task.id in all 6 log statements to avoid
  logging user-authored content (PII).
- Add #[cfg(test)] test_mocks module with atomic state so routing tests
  can force deterministic failures from execute_with_local_model /
  execute_with_agent_analysis without depending on real provider state
  (Ollama running, cloud credentials).
- Both routing tests now exercise branch selection independently of
  infrastructure, per review feedback.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/openhuman/subconscious/executor.rs (1)

103-151: 💤 Low value

Align log levels across text-task branches.

use_local_for_subconscious()=true logs at debug! (Line 107), while the cloud-fallback branch logs at info! (Line 121). Both fire on every tick for the same class of work (simple text-only tasks); when local AI is disabled, this becomes an info-level entry per task per tick. The completion log on Line 134 is already debug!, so the entry log is the outlier. Recommend debug! for symmetry and to match the per-tick cadence — info! is more appropriate for one-off state transitions, which the write-intent (Line 68) and needs_agent (Line 83) branches arguably are.

As per coding guidelines: "Use log / tracing at debug / trace level; include stable grep-friendly prefixes ([domain], [rpc]) and correlation fields".

♻️ Suggested change
-            info!(
-                "[subconscious:executor] text task: id={} — local AI disabled, using cloud fallback",
-                task.id
-            );
+            debug!(
+                "[subconscious:executor] text task: id={} — local AI disabled, using cloud fallback",
+                task.id
+            );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openhuman/subconscious/executor.rs` around lines 103 - 151, The
cloud-fallback branch logs the text-task start at info! while the local path
uses debug! causing inconsistent per-tick noise; in the else branch that calls
execute_with_agent_analysis (the branch guarded by
config.local_ai.use_local_for_subconscious() == false) change the info! call to
debug! and keep the same grep-friendly prefix and correlation field (the
"[subconscious:executor] text task: id={}" message) so both simple text-only
task entry logs use debug level and match the completion debug! log and the
local-model branch.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/openhuman/subconscious/executor.rs`:
- Around line 103-151: The cloud-fallback branch logs the text-task start at
info! while the local path uses debug! causing inconsistent per-tick noise; in
the else branch that calls execute_with_agent_analysis (the branch guarded by
config.local_ai.use_local_for_subconscious() == false) change the info! call to
debug! and keep the same grep-friendly prefix and correlation field (the
"[subconscious:executor] text task: id={}" message) so both simple text-only
task entry logs use debug level and match the completion debug! log and the
local-model branch.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 15453678-b17c-41a4-bf9d-7c41c9cc9bc0

📥 Commits

Reviewing files that changed from the base of the PR and between ff959aa and a51b024.

📒 Files selected for processing (1)
  • src/openhuman/subconscious/executor.rs

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 12, 2026
@senamakel senamakel merged commit 00fda56 into tinyhumansai:main May 13, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants