Commit Graph

21 Commits

Author SHA1 Message Date
YeonGyu-Kim c5c5bc36bc fix(delegate-task): consume fallback chain on sendSyncPrompt failure (#2691)
setSessionFallbackChain stored the fallback chain but the sync path
never consumed it when sendSyncPrompt returned an error. Added a
retry loop that iterates getNextFallback() until the prompt succeeds
or the chain is exhausted, preserving the finally-block cleanup.

🤖 Generated with OhMyOpenCode assistance
https://github.com/code-yeongyu/oh-my-opencode
2026-04-12 02:30:32 +09:00
YeonGyu-Kim ae3a8d628b fix(delegate-task): tighten subagent depth guard + add regression smoke tests
The depth limit (default maxDepth=3) was being silently bypassed when
sync-task.ts could not reach the manager's spawn enforcement methods --
the fallback hardcoded childDepth: 1, allowing infinite recursion of
delegate_task calls in degraded environments.

This was hard to catch because:
1. The fallback path took the dangerous default silently (no log).
2. There were no end-to-end smoke tests asserting that the depth value
   coming back from reserveSubagentSpawn is actually used.
3. The unit tests for resolveSubagentSpawnContext only covered error
   cases, not the actual depth calculation.

Changes:
- sync-task.ts: split the spawnContext fallback into an explicit if/else
  with a WARNING log when the manager is missing enforcement methods.
  This makes the dangerous path observable in logs.
- subagent-spawn-limits.test.ts: add depth calculation regression tests
  (root, depth-1, depth-2, depth at max, parent cycle detection).
- sync-task.test.ts: add two regression smoke tests:
  1. depth limit error from reserveSubagentSpawn must be propagated and
     must NOT create the session.
  2. spawnDepth recorded in metadata must equal what reserveSubagentSpawn
     returns -- guards against silent fallback to childDepth: 1.

15 new spawn-limits tests + 2 new sync-task tests pass.
Full suite: 5105 pass, 0 fail.
2026-04-07 19:56:51 +09:00
YeonGyu-Kim d5dfaaa3ad fix(delegate-task): remove kimi from unstable agent detection, harden callID resolution for metadata store
- Remove kimi from auto-detected unstable agents in category-resolver (only gemini/minimax remain)
- Add resolveCallID() to safely resolve callID/callId/call_id variants from tool context
- Use resolveCallID across all 5 delegate task execution paths (sync, background, unstable, continuations)
- Update writing category test to verify kimi runs sync when kimi provider is available
- Add atlas metadata preservation tests confirming tool-execute-after does not clobber metadata

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-04-05 15:30:36 +09:00
Ryan Dielhenn 571dfe23a4 add bool value: tdd to sisyphus_agent config 2026-03-28 09:34:58 -07:00
YeonGyu-Kim 5898d36321 Merge pull request #2575 from apple-ouyang/fix/issue-2571-subagent-safeguards
fix(delegate-task): add subagent turn limit and model routing transparency
2026-03-25 21:46:01 +09:00
Ravi Tharuma a77a16c494 feat(config): support object-style fallback_models with per-model settings
Add support for object-style entries in fallback_models arrays, enabling
per-model configuration of variant, reasoningEffort, temperature, top_p,
maxTokens, and thinking settings.

- Zod schema for FallbackModelObject with full validation
- normalizeFallbackModels() and flattenToFallbackModelStrings() utilities
- Provider-agnostic model resolution pipeline with fallback chain
- Session prompt params state management
- Fallback chain construction with prefix-match lookup
- Integration across delegate-task, background-agent, and plugin layers
2026-03-25 11:04:49 +01:00
Ouyang Xingyuan f2b26e5346 fix(delegate-task): add subagent turn limit and model routing transparency
原因:
- subagent 无最大步数限制,陷入 tool-call 死循环时可无限运行,造成巨额 API 费用
- category 路由将 subagent 静默切换到与父 session 不同的模型,用户完全无感知

改动:
- sync-session-poller: 新增 maxAssistantTurns 参数(默认 300),每检测到新 assistant 消息
  计数一次,超限后调用 abortSyncSession 并返回明确错误信息
- sync-task: task 完成时在返回字符串中显示实际使用的模型;若与父 session 模型不同,
  加 ⚠️ 警告提示用户发生了静默路由

影响:
- 现有行为不变,maxAssistantTurns 为可选参数,默认值 300 远高于正常任务所需轮次
- 修复 #2571:用户一个下午因 Sisyphus-Junior 死循环 + 静默路由到 Gemini 3.1 Pro
  烧掉 $350+,且 OpenCode 显示费用仅为实际的一半
2026-03-15 12:05:42 +08:00
YeonGyu-Kim a179ebe0b9 Count sync subagent spawns against descendant limits 2026-03-11 20:50:11 +09:00
YeonGyu-Kim 4a39c83eb5 Limit recursive subagent spawning 2026-03-11 20:50:10 +09:00
YeonGyu-Kim d6b0e564bf feat(delegate-task): unify TUI metadata by adding model field to all 5 executor paths 2026-03-04 18:31:19 +09:00
Lynricsy d09cf56e15 feat(delegate-task): ⚙️ make sync subagent timeout configurable via syncPollTimeoutMs
Allow users to set `background_task.syncPollTimeoutMs` in config to override
the default 10-minute sync subagent timeout. Affects sync task, sync continuation,
and unstable agent task paths. Minimum value: 60000ms (1 minute).

Co-authored-by: Wine Fox <fox@ling.plus>
2026-02-27 16:17:39 +08:00
YeonGyu-Kim 481106a12e Merge branch 'pr-1959' into dev
# Conflicts:
#	src/hooks/index.ts
#	src/plugin/event.ts
#	src/tools/delegate-task/sync-task.ts
2026-02-21 02:49:39 +09:00
um1ng d9072b4a98 fix(runtime-fallback): address cubic AI review issues
- Add normalizeFallbackModels helper to centralize string/array normalization (P3)
- Export RuntimeFallbackConfig and FallbackModels types from config/index.ts
- Fix agent detection regex to use word boundaries for sessionID matching
- Improve tests to verify actual fallback switching logic (not just log paths)
- Add SessionCategoryRegistry cleanup in executeSyncTask on completion/error (P2)
- All 24 runtime-fallback tests pass, 115 delegate-task tests pass
2026-02-21 02:37:57 +09:00
Ultrawork Bot 7aafa13b21 feat(fallback_models): complete init-time and runtime integration
Implement full fallback_models support across all integration points:

1. Model Resolution Pipeline (src/shared/model-resolution-pipeline.ts)
   - Add userFallbackModels to ModelResolutionRequest
   - Process user fallback_models before hardcoded fallback chain
   - Support both connected provider and availability checking modes

2. Agent Utils (src/agents/utils.ts)
   - Update applyModelResolution to accept userFallbackModels
   - Inject fallback_models for all builtin agents (sisyphus, oracle, etc.)
   - Support both single string and array formats

3. Model Resolver (src/shared/model-resolver.ts)
   - Add userFallbackModels to ExtendedModelResolutionInput type
   - Pass through to resolveModelPipeline

4. Delegate Task Executor (src/tools/delegate-task/executor.ts)
   - Extract category fallback_models configuration
   - Pass to model resolution pipeline
   - Register session category for runtime-fallback hook

5. Session Category Registry (src/shared/session-category-registry.ts)
   - New module: maps sessionID -> category
   - Used by runtime-fallback to lookup category fallback_models
   - Auto-cleanup support

6. Runtime Fallback Hook (src/hooks/runtime-fallback/index.ts)
   - Check SessionCategoryRegistry first for category fallback_models
   - Fallback to agent-level configuration
   - Import and use SessionCategoryRegistry

Test Results:
- runtime-fallback: 24/24 tests passing
- model-resolver: 46/46 tests passing

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-21 02:30:01 +09:00
VespianRex bf51919a79 Address review feedback for fallback fixes 2026-02-20 17:46:12 +02:00
VespianRex f5f1d1d4c2 Fix model fallback across main/background/sync agents 2026-02-20 17:45:53 +02:00
YeonGyu-Kim 7427922e6f fix(delegate-task): ensure subagentSessions cleanup on all exit paths
Added outer finally block so subagentSessions.delete(syncSessionID)
runs even on early return from sendSyncPrompt error.
2026-02-11 00:45:51 +09:00
YeonGyu-Kim 087ce06055 refactor(delegate-task): inject sync task deps for test isolation 2026-02-10 22:54:30 +09:00
YeonGyu-Kim df0b9f7664 fix(delegate-task): Wave 1 - fix polling timeout, resource cleanup, tool restrictions, idle dedup, auth-plugins JSONC, CLI runner hang
- fix(delegate-task): return error on poll timeout instead of silent null
- fix(delegate-task): ensure toast and session cleanup on all error paths with try/finally
- fix(delegate-task): apply agent tool restrictions in sync-prompt-sender
- fix(plugin): add symmetric idle dedup to prevent double hook triggers
- fix(cli): replace regex-based JSONC editing with jsonc-parser in auth-plugins
- fix(cli): abort event stream after completion and restore no-timeout default

All changes verified with tests and typecheck.
2026-02-10 22:00:54 +09:00
YeonGyu-Kim c9be2e1696 refactor: extract model selection logic from delegate-task into focused modules
- Create available-models.ts for model availability checking
- Create model-selection.ts for category-to-model resolution logic
- Update category-resolver, subagent-resolver, and sync modules to import
  from new focused modules instead of monolithic sources
2026-02-08 18:03:15 +09:00
YeonGyu-Kim 29155ec7bc refactor: wave 1 - extract leaf modules, rename catch-all files, split index.ts hooks
- Split 25+ index.ts files into hook.ts + extracted modules
- Rename all catch-all utils.ts/helpers.ts to domain-specific names
- Split src/tools/lsp/ into ~15 focused modules
- Split src/tools/delegate-task/ into ~18 focused modules
- Separate shared types from implementation
- 155 files changed, 60+ new files created
- All typecheck clean, 61 tests pass
2026-02-08 13:57:26 +09:00