Skip to content

feat(agent): re-apply agent.ts robustness improvements from v2026.3.1/v2026.3.2 (#2203)#2259

Merged
alexey-pelykh merged 1 commit intomainfrom
feat/2203-agent-robustness-improvements
Apr 10, 2026
Merged

feat(agent): re-apply agent.ts robustness improvements from v2026.3.1/v2026.3.2 (#2203)#2259
alexey-pelykh merged 1 commit intomainfrom
feat/2203-agent-robustness-improvements

Conversation

@alexey-pelykh
Copy link
Copy Markdown

Summary

Re-apply upstream robustness and code quality improvements to src/commands/agent.ts that were lost during the PR #2191 wholesale restoration. All changes adapted for the fork's ChannelBridge dispatch architecture.

  • mergeSessionEntry with OverrideFieldClearedByDelete: persistSessionEntry now uses merge-then-persist instead of direct overwrite, preventing concurrent session clobber
  • Session-expired retry flow: Detects session_expired from bridge errors, clears stale CLI session ID, retries once with fresh session
  • runAgentAttempt extraction: Inline bridge dispatch logic extracted to standalone function with typed params
  • Subsystem logger: createSubsystemLogger("commands/agent") for structured per-subsystem logging
  • runBridgeWithSession closure: DRY for initial and retry dispatch (adapted from upstream's runCliWithSession)

Blocked improvements (noted for tracking)

  • trigger: "user" field: SessionEntry has no trigger field; the upstream usage was a parameter to the gutted runEmbeddedPiAgent

Closes #2203

Test plan

  • All 32 existing agent command tests pass
  • TypeScript type-check clean (tsgo --noEmit)
  • Linter clean (oxlint --type-aware)
  • Formatter clean (oxfmt --check)
  • Pre-commit hooks pass (format + typecheck + lint)
  • No gutted subsystem imports re-introduced (no pi-embedded, model-catalog, memory, skills, SecretRef, sandbox)

🤖 Generated with Claude Code

…/v2026.3.2 (#2203)

Re-apply upstream improvements to src/commands/agent.ts that were
lost during the PR #2191 wholesale restoration. Adapted for the
fork's ChannelBridge dispatch architecture.

Applied:
- Subsystem logger: createSubsystemLogger("commands/agent")
- mergeSessionEntry with OverrideFieldClearedByDelete tracking in
  persistSessionEntry — prevents concurrent session clobber
- runAgentAttempt extraction — extracts bridge dispatch to standalone
  function with typed params
- Session-expired retry flow — detects session_expired from bridge
  errors, clears stale CLI session, retries once
- runBridgeWithSession closure — DRY for initial and retry dispatch

Blocked (noted for tracking):
- trigger: "user" field — SessionEntry has no trigger field; was a
  pi-embedded parameter in upstream

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alexey-pelykh alexey-pelykh merged commit 27d5b65 into main Apr 10, 2026
10 checks passed
@alexey-pelykh alexey-pelykh deleted the feat/2203-agent-robustness-improvements branch April 10, 2026 23:23
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.

Re-apply agent.ts robustness improvements from v2026.3.1/v2026.3.2

1 participant