Skip to content

Validate session IDs before resume and persist Claude stderr#57

Open
Richuthegreat14 wants to merge 4 commits into
earlyaidopters:mainfrom
Richuthegreat14:fix/session-id-validation-stderr-logging
Open

Validate session IDs before resume and persist Claude stderr#57
Richuthegreat14 wants to merge 4 commits into
earlyaidopters:mainfrom
Richuthegreat14:fix/session-id-validation-stderr-logging

Conversation

@Richuthegreat14

Copy link
Copy Markdown

Summary

  • validate session IDs before passing
    esume to the Claude subprocess
  • fall back to a fresh session when session IDs are invalid instead of forwarding bad --resume input
  • persist full subprocess stderr to logs/claude-subprocess-stderr.log while keeping structured logger warnings

Validation

  • npm run typecheck
  • npm test

Artifacts

Co-Authored-By: Oz oz-agent@warp.dev

Richuthegreat14 and others added 4 commits May 22, 2026 18:33
Key changes:
- Windows: set HOME from USERPROFILE, unset CLAUDECODE for nested sessions,
  explicit binary path to avoid PATHEXT issues
- Agent timeout default changed to 0 (unlimited) with safe clearTimeout guards
- Surface agent errors to users for easier diagnostics
- Downgrade memory-ingest missing-key logs; skip OAuth file check when using keychain
- Upgrade better-sqlite3 to v12, revert Gemini model to 2.0-flash
- Expand esbuild platform binaries for cross-platform builds

Co-Authored-By: Claude Opus 4.7 (1M context) <<EMAIL>>
- add UUID validation guard so invalid session IDs do not get passed as --resume
- fall back to fresh session when session ID format is invalid
- persist full Claude subprocess stderr to logs/claude-subprocess-stderr.log for debugging
- keep structured stderr warnings in existing logger output

Co-Authored-By: Oz <oz-agent@warp.dev>
Threadbury pushed a commit to Threadbury/claudeclaw that referenced this pull request Jun 14, 2026
…duled tasks (earlyaidopters#57)

The mission_task and scheduled_task execution paths were calling runAgent
with `model` parameter as undefined, causing the SDK to fall through to
its default model regardless of agent.yaml `model:` field. Interactive
Telegram path (bot.ts:519) was honoring the yaml correctly via
agentDefaultModel, but background tasks were not.

Verified via temporary diagnostic log: post-fix, research/Scooby's
runAgent receives 'claude-opus-4-7' and viral receives 'claude-sonnet-4-6'
matching their yaml configs. Pre-fix, both received undefined.

Impact: every model registry update (e.g. yesterday's Scooby->Opus 4.7
and Viral->Sonnet 4.6 bumps) was silently a no-op for any background
task. Affects only mission_tasks + scheduled_tasks — interactive paths
were always correct.

Three-line change:
- Import agentDefaultModel from config.js
- Pass it as positional arg 5 (model) at line 95 (scheduled tasks)
- Pass it as positional arg 5 (model) at line 169 (mission tasks)

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Threadbury pushed a commit to Threadbury/claudeclaw that referenced this pull request Jun 14, 2026
…ToAgent (#67)

## Bug

`src/orchestrator.ts:209` calls `runAgent()` with `undefined` for the
`model` parameter inside `delegateToAgent`. When a sync delegation
(`@research: ...` from the chat parser) fires, the SDK falls through to
its default model regardless of the `model:` field declared in the
target specialist's `agent.yaml`.

Same theme as earlyaidopters#57 (`fix(scheduler): pass agentDefaultModel to runAgent
for mission + scheduled tasks`), but the orchestrator path is a separate
callsite that earlyaidopters#57 did not touch.

## Impact

For any user with non-default `model:` values across agents (e.g. main
on `claude-opus-4-7`, specialists on `claude-sonnet-4-6`), sync
delegations from the orchestrator have been silently running on the SDK
default. The interactive DM path to each specialist's own bot already
honoured the override (it goes through `bot.ts` which passes
`agentDefaultModel`), but every `@<id>:` delegation from the
orchestrator landed on the wrong model.

Empirically: in a deploy where specialists were configured as
`claude-sonnet-4-6` while main remained on Opus default, a delegate
roundtrip took ~68s pre-fix vs ~10s post-fix — consistent with the
Sonnet vs Opus latency ratio, confirming the target's model was being
ignored.

## Why `agentConfig.model`, not `agentDefaultModel`

`delegateToAgent` runs **in-process** inside the orchestrator (main).
The module-level `agentDefaultModel` exported from `config.ts` is set
once per process at startup, from the *caller* agent's `agent.yaml`.
Inside main's process that's main's model (typically `undefined` since
main doesn't have an agent.yaml in the default layout), NOT the
target's.

The target's config is already loaded on the line above the runAgent
call (`const agentConfig = loadAgentConfig(agentId)` at line 174), so
`agentConfig.model` is the correct source. Inline comment in the diff
documents the distinction so a future contributor doesn't "simplify" it
to `agentDefaultModel` and silently break delegations.

## Fix

One field in `src/orchestrator.ts`: pass `agentConfig.model` as the
positional `model` arg (instead of `undefined`) to the `runAgent()`
call inside `delegateToAgent`. No new imports (`loadAgentConfig` is
already imported and used a few lines above).

No behaviour change for users with no `model:` field set in their
agents — `agentConfig.model` is `string | undefined`, so the
fallthrough to SDK default still applies. Test changes not required;
existing tests don't exercise this parameter.

## Relation to prior work

- earlyaidopters#57 (merged) fixed the same theme in `src/scheduler.ts` for
  `runAgent` call sites that run inside the *target* process (where
  `agentDefaultModel` is correctly the target's). The orchestrator
  callsite needs `agentConfig.model` instead because it runs
  in-process from a different agent.
- Conceptually adjacent to earlyaidopters#47 — model overrides should be honoured
  consistently across surfaces.
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.

1 participant