Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

[bug] SendGate session id and a false downgrade at inference level low

Open IvanLeontev-stack opened this issue 1 week ago • 1 comments

What happened

8.761.0: SendGate reads only CLAUDE_SESSION_ID, and inference at level low reports a model downgrade on the default path

Summary

LifeOS 8.761.0 (tag v8.761.0, fb9aef46). Every location below was read in that tag. Paths are from the repository root. Where a step says "sandbox", the code was run from a copy of LifeOS/install/ with HOME set to a temporary directory and no network.

Related issues are linked where they exist. None of these is a duplicate as far as I can find.


1. SendGate stamps sent items send-tool when only CLAUDE_CODE_SESSION_ID is set, so complaints do not link to those outputs

Where: LifeOS/install/LIFEOS/TOOLS/lib/SendGate.ts:166 and :572

const sessionIdOf = (deps: GateDeps): string => deps.sessionId ?? process.env.CLAUDE_SESSION_ID ?? "";
...
session_id: m.session_id ?? process.env.CLAUDE_SESSION_ID ?? "send-tool", skill: m.skill ?? null,

What happens. Claude Code gives Bash children CLAUDE_CODE_SESSION_ID; in a Claude Code Bash call CLAUDE_SESSION_ID is empty (step 1). recordSentAll (:596-604) passes no session_id, so unless something exported CLAUDE_SESSION_ID, each sent item's output line gets session_id: "send-tool". outputIdsSince (LIFEOS/ERRATA/Capture.ts:210-213) matches lines by the session id from the hook payload and does not find these lines. An erratum filed in that session then misses them in context.output_ids, which cuts the complaint → output → receipt chain described in LIFEOS/DOCUMENTATION/LifeOs/HillClimbing.md:54.

Steps:

  1. In a Claude Code Bash call: echo "[$CLAUDE_SESSION_ID] [$CLAUDE_CODE_SESSION_ID]". The first is empty.
  2. Sandbox, same environment: put a file <sha256>.txt in a proof dir. Call recordSent({ channel: "imessage", destination: "handoff", sha256, receipt_id: "r", decision: "allowed", reason: "t" }, { proofDir, ledgerDir, emit: () => {} }). Then call outputIdsSince(process.env.CLAUDE_CODE_SESSION_ID, <time before the call>, ledgerDir).

Expected: the line carries the session id, and outputIdsSince returns its output_id. Actual: the line has session_id=send-tool, and outputIdsSince returns []. With CLAUDE_SESSION_ID also exported, the same call returns one id.

Minimal fix: read CLAUDE_CODE_SESSION_ID first, the way LIFEOS/TOOLS/lib/ModelUse.ts:25 and LIFEOS/TOOLS/CodexProgress.ts:164 already do.

-const sessionIdOf = (deps: GateDeps): string => deps.sessionId ?? process.env.CLAUDE_SESSION_ID ?? "";
+const sessionIdOf = (deps: GateDeps): string => deps.sessionId ?? (process.env.CLAUDE_CODE_SESSION_ID || process.env.CLAUDE_SESSION_ID || "");
@@
-      session_id: m.session_id ?? process.env.CLAUDE_SESSION_ID ?? "send-tool", skill: m.skill ?? null,
+      session_id: m.session_id ?? (sessionIdOf(deps) || "send-tool"), skill: m.skill ?? null,

Same class, still reading only CLAUDE_SESSION_ID in 8.761.0 (rg -n 'process.env.CLAUDE_SESSION_ID' LifeOS/install):

  • skills/Errata/Tools/Er.ts:45: /er run from Bash without --session files session_id: null and output_ids: [].
  • LIFEOS/TOOLS/ApiLane.ts:236
  • skills/Assay/Tools/Proof.ts:4002
  • LIFEOS/TOOLS/current-work-dir.ts:86

hooks/lib/events.ts:111 is the same pattern and is already fixed in source under #2329.


2. inference() at level low reports a model downgrade on the default path

Where: LifeOS/install/LIFEOS/TOOLS/Inference.ts:634

const expectedTier = (!modelOverride && options.model ? parseClaudeId(options.model)?.tier : null) ?? EFFORT_MODEL[level];

What happens. On the default Anthropic subscription path, low spawns haiku (Inference.ts:306-307: "Low is Haiku on the subscription, not the EFFORT_MODEL low rung"). But with no options.model, the expected tier falls back to EFFORT_MODEL.low, which is "sonnet" (LIFEOS/TOOLS/models.ts:107). verifyExecutedModel sees a haiku id and returns downgraded: true. That one result has three effects: a best-effort model-verification.jsonl row (:639-640), a ⚠️ DOWNGRADED from requested tier line on stderr from the CLI wrapper (:1098), and modelDowngraded: true returned to the caller.

Steps:

  1. bun -e 'import {verifyExecutedModel} from "./LIFEOS/TOOLS/Inference.ts"; import {EFFORT_MODEL} from "./LIFEOS/TOOLS/models.ts"; console.log(verifyExecutedModel({"claude-haiku-4-5-20251001":{outputTokens:12}}, EFFORT_MODEL.low))'
  2. On a live install, the same path: bun LIFEOS/TOOLS/Inference.ts --level low "Reply OK" "ping".

Expected: downgraded: false, because haiku is what low is configured to run. Actual: { executed: "claude-haiku-4-5-20251001", downgraded: true }. I ran step 1. I did not run step 2, which needs the claude CLI. Line 1098 prints the warning whenever modelDowngraded is true.

Minimal fix: compare against the tier of the model this call actually spawned, not the EFFORT_MODEL rung. The smallest form:

-      const expectedTier = (!modelOverride && options.model ? parseClaudeId(options.model)?.tier : null) ?? EFFORT_MODEL[level];
+      const expectedTier = (!modelOverride && options.model ? parseClaudeId(options.model)?.tier : null)
+        ?? (!modelOverride && !options.model && level === 'low' ? 'haiku' : EFFORT_MODEL[level]);

Related: #2748 (fixed in source, not in 8.761.0) handles a tier name passed in options.model. As described, that fix still falls back to EFFORT_MODEL[level] when options.model is unset, which is the default low call. If the new tier-name resolver is applied to the spawned model, not to options.model, it covers both cases.

Details

  • Kind: bug
  • LifeOS version: 8.761.0

Filed with the LifeOS /feedback command. The reporter approved this exact text before it was sent; paths, secrets and personal details were stripped locally.

IvanLeontev-stack avatar Nov 26 '26 09:11 IvanLeontev-stack

[!NOTE] 🤖 Kai (AI assistant) responding on behalf of Daniel Miessler

Thanks @IvanLeontev-stack for the report.

This is fixed in our source and goes out in the next release. SendGate associates sent and blocked outputs with the Claude Code session so they appear in that session's errata. Inference calls that run at the requested low tier are recorded without a false downgrade.

Please reopen if it still happens after you upgrade.

danielmiessler avatar Dec 02 '26 09:12 danielmiessler