Commit Graph

3407 Commits

Author SHA1 Message Date
YeonGyu-Kim e62d5d7a22 fix(agents): strip ZWSP ordering prefixes in session state, config lookups, and override protection
Prevent ZWSP sort prefixes from leaking into stored agent names, config
key lookups, and override-protection normalization. Ensures prefixed
list-display names resolve correctly throughout the pipeline.

🤖 Generated with [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode) assistance
2026-04-06 18:07:26 +09:00
YeonGyu-Kim 178b635d72 feat(agents): add ZWSP stable-sort prefixes for core agent list ordering
Populate AGENT_LIST_SORT_PREFIXES for sisyphus/hephaestus/prometheus/atlas
so the TUI agent list renders in canonical order. Update dependent tests
to use getAgentListDisplayName() instead of hardcoded display strings.

🤖 Generated with [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode) assistance
2026-04-06 18:07:07 +09:00
YeonGyu-Kim 88280d0e4d fix(agents): keep prometheus and atlas in canonical core order 2026-04-06 18:02:09 +09:00
YeonGyu-Kim 0c1202e480 fix(tests): resolve CI test isolation failures in OAuth refresh and ralph-loop
- provider.test.ts: reset discovery cache before/after refresh tests to prevent
  cross-test contamination via module-level discoveryCache singleton
- completion-promise-session-negative.test.ts: update negative test case to use
  non-oracle agent (hephaestus) since oracle tool_result VERIFIED detection was
  intentionally added in 56f2a9df
2026-04-06 17:48:38 +09:00
YeonGyu-Kim 61083d499d fix(oauth+errors): OAuth silent refresh, quota STOP patterns, compaction loop cap
Bug fixes:
1. OAuth token refresh (#3149): buildHttpRequestInit() now attempts silent refresh
   via refresh_token before triggering full browser re-auth. Added refresh() method
   to McpOAuthProvider. Includes test isolation fix for discovery mock.

2. Quota error STOP (#3126): Added STOP_MESSAGE_PATTERNS in model-error-classifier
   that take precedence over RETRYABLE_MESSAGE_PATTERNS. Message-only quota errors
   now non-retryable. Runtime-fallback: quota_exceeded with 'retrying in' signal
   still triggers fallback (provider-managed auto-retry). Restored removed patterns.

3. Compaction loop (#3127): MAX_RECOVERY_ATTEMPTS=3 cap + additional suppression
   guard from opencode session in degradation monitor.

Also: refactored extractAutoRetrySignal to auto-retry-signal.ts, new regression
tests for quota classifier and compaction degradation monitor.
2026-04-06 17:40:12 +09:00
YeonGyu-Kim 6c4e0b69a5 fix(agents): enforce Sisyphus->Hephaestus->Prometheus->Atlas assembly order
Extract hephaestus into agentConfig before prometheus so the config
handler naturally assembles agents in the canonical order instead of
relying solely on reorderAgentsByPriority to fix the wrong intermediate
order. Also fix test data that had atlas/prometheus swapped and add
missing hephaestus to agent-config-integration test lists.
2026-04-06 17:18:47 +09:00
YeonGyu-Kim 56f2a9df3a fix(ralph-loop): detect oracle VERIFIED tool results in session messages
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-06 17:18:47 +09:00
YeonGyu-Kim 137c2459f7 fix(prompt): prevent immediate BackgroundOutput polling after background task launch
Tool return values contained CTAs ("Use background_output to check") that
caused models to immediately poll instead of waiting for <system-reminder>
notifications. Unified all 5 tool return messages with explicit "Do NOT call
background_output now" guard, added pre-notification warning to BackgroundOutput
tool description, and strengthened Background Result Collection sections across
all 3 Sisyphus prompt variants (default, gpt-5-4, main) with BLOCKING
anti-pattern enforcement.

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2026-04-06 17:18:47 +09:00
YeonGyu-Kim 5ad011de32 fix(compaction): cap recovery attempts to prevent infinite compaction loop (#3127)
Add MAX_RECOVERY_ATTEMPTS (3) guard to post-compaction degradation recovery.
On models like Kimi/Minimax that repeatedly generate no-text responses,
the recovery loop would trigger indefinitely as each compaction reset the
recovery counter via onSessionCompacted.

The recovery count now persists across compaction cycles per session and
is only reset on session deletion (clear()), not on every compaction.
2026-04-06 17:01:10 +09:00
YeonGyu-Kim f69234ab7e fix(error-classifier): quota/billing errors are non-retryable STOP (fixes #3126)
Add STOP_MESSAGE_PATTERNS that take precedence over RETRYABLE_MESSAGE_PATTERNS.
Message-only quota errors (no error name) now correctly return false from
isRetryableModelError, preventing unnecessary fallback retries on exhausted quotas.

- quota will reset after...
- quota exceeded
- usage limit has been reached
- free usage limit / billing limit / plan limit / subscription limit
- out of credits / credits exhausted / insufficient credits / insufficient balance

Also add 4 regression tests covering message-only quota STOP cases.
2026-04-06 16:56:17 +09:00
YeonGyu-Kim 9438c89c1c Merge pull request #3148 from MoerAI/fix/remove-installer-subscription-upsell
fix(cli): replace subscription upsell with informational note (fixes #3069)
2026-04-06 16:43:35 +09:00
YeonGyu-Kim bd723b5163 fix(tests): repair test regressions from zod v3 downgrade
- Fix zod/v4 imports in background-task schema tests
- Remove ZWSP prefix from agent-key-remapper test (fixed in #3136)
- Use toMatchObject for openai-only catalog tests (fallback_models added by #3144)
- Replace z.toJSONSchema (zod v4) with zodToJsonSchema (zod v3 compat)
- Fix task-list.ts type narrowing for zod v3 inferred types
2026-04-06 14:43:19 +09:00
YeonGyu-Kim 4659f14ce3 fix(tests): update model-fallback snapshots after installer fallback chain fix 2026-04-06 14:21:32 +09:00
YeonGyu-Kim 213cee27cc fix(types): resolve zod v3 type inference differences in task tools
zod v3 infers .default([]) fields as string[] | undefined in z.infer
output type (unlike v4 which marks them as string[]). Add nullish
coalescing guards and use any[] for the readJsonSafe result array
to avoid the type mismatch in task-list and task-update.
2026-04-06 14:20:30 +09:00
YeonGyu-Kim 22d0895992 Merge pull request #3136 from andrescera/fix/atlas-zwsp-header-leak
fix: remove ZWSP sort prefix that leaks into x-opencode-agent-name header
2026-04-06 13:55:08 +09:00
YeonGyu-Kim f69bb45662 fix(cli): dedupe generated installer fallback models
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-06 13:25:58 +09:00
YeonGyu-Kim 57b152994f fix(cli): preserve installer fallback chains in generated config (#3144)
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-04-06 13:25:58 +09:00
YeonGyu-Kim e43d2ccb96 fix(test): isolate atlas background-task-retry test to prevent setTimeout leak
The test overrides globalThis.setTimeout which conflicts with other atlas
tests when batched by bun test. Adding mock.module forces run-ci-tests.ts
to run this file in its own isolated process.

Also added setSessionAgent for descendant session to fix null agent lookup
in non-SQLite CI environments.
2026-04-06 12:11:50 +09:00
YeonGyu-Kim ed3045cca4 fix(test): register session agent in boulder continuation tests for CI isolation
Tests relied on leaked agent registration from other tests when run locally.
In CI, each test batch runs in isolation so the session agent was null,
causing getLastAgentFromSession to return null and the test to incorrectly
pass (return true instead of false).
2026-04-06 11:56:07 +09:00
YeonGyu-Kim de6c74bfb4 fix(todo-continuation): normalize agent name to config key before promptAsync (#3149)
The todo-continuation-enforcer was passing raw agent names (which could be
display names like 'Sisyphus (Ultraworker)') to promptAsync. These names
contain spaces/parentheses that violate HTTP header specs, causing the
x-opencode-agent-name header validation to fail with 'unknown error' toast.

Added normalizeAgentForPromptKey() that converts display names to config keys
(e.g., 'Sisyphus (Ultraworker)' -> 'sisyphus') before API calls.

TDD: Added regression test that verifies config key is sent to promptAsync.
2026-04-06 11:44:52 +09:00
MoerAI 2f10ff4605 fix(cli): replace subscription upsell with informational note (fixes #3069) 2026-04-06 10:09:13 +09:00
YeonGyu-Kim 75447b7ea2 fix(hephaestus): restrict Oracle to failure-escalation only in GPT-5.4 prompt
Replace generic buildOracleSection (proactive triggers: architecture, significant
work, unfamiliar patterns) with Hephaestus-specific Oracle section that only
permits consultation after 2+ failed attempts. Aligns with autonomous deep worker
identity - try first, escalate later.
2026-04-05 18:32:13 +09:00
YeonGyu-Kim d55a523346 feat(hook-message-injector): enhance boulder continuation injector with lineage support
- Add lineage-aware continuation injection logic
- Support for tracking multiple session types (direct vs appended)
- Update tests for new lineage continuation scenarios
- Add session origin validation in continuation flow

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 18:32:13 +09:00
YeonGyu-Kim d143d2dfa6 feat(run): integrate session origins and agent detection into continuation state
- Update continuation-state to use session_origins from boulder state
- Add isTrackedDescendantSession helper for lineage detection
- Integrate getLastAgentFromSession for reliable agent detection
- Update completion tests for new lineage-aware continuation logic
- Add JSON backend tests for continuation state

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 18:32:13 +09:00
YeonGyu-Kim d555410745 feat(boulder-state): add session_origins tracking for direct vs appended sessions
- Add session_origins field to BoulderState type
- Track direct vs appended session origins in storage layer
- Add migration logic for existing state files
- Add comprehensive tests for session origin tracking

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 18:27:53 +09:00
YeonGyu-Kim 1f4ed0057a fix(atlas): use raw agent key instead of display name for API calls (#3138) 2026-04-05 18:26:35 +09:00
YeonGyu-Kim 60ccba38e1 feat(hook-message-injector): enhance boulder continuation injector with lineage support
- Add lineage-aware continuation injection logic
- Support for tracking multiple session types (direct vs appended)
- Update tests for new lineage continuation scenarios
- Add session origin validation in continuation flow

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 17:18:10 +09:00
YeonGyu-Kim d1be22fb1b feat(atlas): update resolvers and index for lineage-aware session resolution
- Update recent-model-resolver for session origin awareness
- Update resolve-active-boulder-session with lineage support
- Add comprehensive test coverage for boulder session resolution
- Add fallback tests for recent model resolver
- Update index tests for new lineage tracking

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 17:18:10 +09:00
YeonGyu-Kim d12c74120d feat(run): integrate session origins and agent detection into continuation state
- Update continuation-state to use session_origins from boulder state
- Add isTrackedDescendantSession helper for lineage detection
- Integrate getLastAgentFromSession for reliable agent detection
- Update completion tests for new lineage-aware continuation logic
- Add JSON backend tests for continuation state

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 17:18:10 +09:00
YeonGyu-Kim b37bc4fb78 feat(atlas): integrate session origins into background launch tracking
- Update background-launch-session-tracking to track session origins
- Add tests for lineage-aware retry scheduling
- Update tool-execute-after to support new tracking
- Add comprehensive tests for background launch continuation

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 17:18:10 +09:00
YeonGyu-Kim cd71ced0fb feat(atlas): add canContinueTrackedBoulderSession for lineage-aware continuation
- Implement canContinueTrackedBoulderSession helper function
- Add lineage validation for appended descendant sessions
- Add agent matching logic for tracked sessions
- Add comprehensive tests for lineage continuation scenarios
- Add persisted lineage tests for boulder state tracking

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 17:18:10 +09:00
YeonGyu-Kim 9199dd545f feat(atlas): enhance session-last-agent with timestamp-based ordering
- Sort messages by creation timestamp for accurate last agent detection
- Add fallback to filename sorting for deterministic ordering
- Add JSON backend test coverage
- Update SQLite backend tests for timestamp-aware sorting

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 17:18:10 +09:00
YeonGyu-Kim ec49bd553f feat(boulder-state): add session_origins tracking for direct vs appended sessions
- Add session_origins field to BoulderState type
- Track direct vs appended session origins in storage layer
- Add migration logic for existing state files
- Add comprehensive tests for session origin tracking

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 17:18:10 +09:00
YeonGyu-Kim afd554b2d9 fix(delegate-task): validate description parameter and handle undefined in notifications
OpenCode's fromPlugin wrapper skips Zod validation for plugin tools, so
LLMs can omit required args like description without getting an error.
When Atlas orchestrates and the model omits description, it flows through
as undefined to manager.launch() and background task notifications show
'undefined' for all completed tasks.

Two fixes:
- Add runtime validation for description in delegate-task tool (matches
  existing run_in_background and load_skills validation pattern)
- Defensive fallback in notification template: use task ID when
  description is missing instead of rendering 'undefined'
2026-04-05 17:18:10 +09:00
YeonGyu-Kim ae3217369b fix(atlas): use raw agent key instead of display name for API calls (#3138) 2026-04-05 17:04:50 +09:00
YeonGyu-Kim 97ccbf1da3 test: add comprehensive tests for boulder lineage and completion
Add tests for descendant session detection, agent mismatch handling,
background task retry logic, and start-work functionality.

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 15:34:22 +09:00
YeonGyu-Kim 91c1c32c13 feat(atlas): update boulder continuation injector with lineage support
Update continuation injector to work with new lineage detection.
Refine idle event handling for proper subagent session tracking
and agent mismatch detection.

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 15:34:13 +09:00
YeonGyu-Kim 24ca704821 feat(run): implement boulder lineage detection in continuation state
Make getContinuationState async to support client-side lineage checks.
Add hasActiveBoulderContinuation with agent eligibility verification
and subagent session tracking for proper boulder session inheritance.

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 15:34:02 +09:00
YeonGyu-Kim c708d4e526 feat(atlas): add isInjectingContinuation flag to SessionState
Add flag to track when continuation is being injected to prevent
race conditions in boulder session management.

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 15:33:54 +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
YeonGyu-Kim ccfc54ab38 feat(atlas): add background task session tracking with retry scheduling
- Add background-launch-session-tracking.ts to persist delegated sessions
- Add task-context.ts for task context resolution utilities
- Modify idle-event.ts to schedule retries when background tasks are running
- Update tool-execute-after.ts to integrate session tracking
- Add comprehensive tests for background task retry behavior

🤖 Generated with assistance of OhMyOpenCode
2026-04-05 14:59:03 +09:00
YeonGyu-Kim 90407a9789 Merge pull request #3135 from jim80net/fix/agent-not-found-fallback
fix(background-agent): retry with fallback agent on Agent not found
2026-04-05 14:46:08 +09:00
Andres Cera b482e6c609 fix: remove ZWSP sort prefix from Atlas agent name
The \u200B (zero-width space) in AGENT_LIST_SORT_PREFIXES leaked into
the x-opencode-agent-name HTTP header, causing invalid header errors.

Agent ordering is handled by agent-priority-order.ts via numeric order
fields and insertion order — the ZWSP prefix was redundant.
2026-04-05 00:43:05 -05:00
auyua9 0bb16e5149 fix(session-manager): use sdk data in getSessionInfo 2026-04-05 14:38:13 +09:00
Jim Park f8d086ded1 fix: remove overly broad agent+undefined error pattern
The (message.includes("agent") && message.includes("undefined"))
pattern could match unrelated errors like "The agent returned undefined
for the configuration", triggering a false fallback that hides the real
failure.

The two precise patterns are sufficient:
- "Agent not found" — canonical SDK validation error
- "agent.name" — property access error on undefined agent config

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 22:31:22 -07:00
YeonGyu-Kim d7c2b6249b fix(config): fall back to legacy path when migration fails and use canonical basename everywhere (#3133)
Root cause: loadPluginConfig() unconditionally switched userConfigPath to the
canonical name after calling migrateLegacyConfigFile(), even when migration
failed (e.g. file lock on Windows, permission denied). This left the config
path pointing to a non-existent file, so the plugin config silently loaded
as empty defaults.

Additionally, several fallback/default paths were hardcoded to the legacy
'oh-my-opencode' basename instead of using CONFIG_BASENAME ('oh-my-openagent'),
causing CLI config commands (writeOmoConfig, detectCurrentConfig) to write to
the wrong filename.

Changes:
- plugin-config.ts: check migrateLegacyConfigFile() return value; only switch
  to canonical path if migration succeeded OR the canonical file already exists
- opencode-config-dir.ts: use CONFIG_BASENAME for omoConfig path in
  getOpenCodeConfigPaths()
- config-context.ts: getOmoConfigPath() now uses detectPluginConfigFile() to
  find whichever name variant actually exists on disk
- plugin-config.ts: default fallback paths use CONFIG_BASENAME instead of
  hardcoded legacy name
- Added test: loadPluginConfig still loads config when migration fails
  (read-only directory simulation)
2026-04-05 14:27:24 +09:00
Jim Park 51508c4949 fix: address cubic review — broaden error detection, add test coverage
1. isAgentNotFoundError now handles:
   - Plain objects with .message field (not just Error instances)
   - "agent.name"/"undefined" error variants from SDK validation
   - The original "Agent not found" format

2. New tests:
   - agent.name/undefined error variant triggers fallback
   - Plain object errors with .message field trigger fallback
   - "fallback also fails" test now verifies retry was attempted (callCount=2)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 22:17:22 -07:00
Jim Park 9470cbe090 fix: address systems review findings for agent-not-found fallback
1. [HIGH] Tool restrictions recomputed for fallback agent via
   buildFallbackBody() — no longer inherits original agent's restrictions.

2. [HIGH] Double-retry race prevented — handleSessionErrorEvent now
   returns early for agent-not-found errors, since the prompt catch
   block already handles them with agent fallback. This prevents
   tryFallbackRetry from racing with a model-level retry on the same
   error (the "not found" pattern in RETRYABLE_MESSAGE_PATTERNS).

3. [MEDIUM] task.agent updated to FALLBACK_AGENT after successful
   fallback — notifications, toast, and logging reflect actual agent.

4. [MEDIUM] FALLBACK_AGENT exported from spawner.ts and imported into
   manager.ts — single source of truth.

5. [LOW] resumeTask fallback now uses promptWithModelSuggestionRetry
   (consistent with startTask), getting timeout protection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 22:13:05 -07:00
YeonGyu-Kim 7b7526e2f6 docs(src): update counts across tools, features, config, cli AGENTS.md
- tools: 15 -> 16 dirs, writing model kimi-k2p5 -> gemini-3-flash
- features: builtin skills 6 -> 8 (+review-work, +ai-slop-remover)
- config: schema files 24 -> 27 (+git-env-prefix, model-capabilities, openclaw)
- cli: commands 5 -> 6 (+refresh-model-capabilities)
- plugin-handlers: 13 -> 14 non-test files
- shared: 95+ -> 100+ utility files
2026-04-05 14:12:31 +09:00
YeonGyu-Kim 3697809c11 docs(hooks): update hook inventory to match current 52 hooks
- Session: 23 -> 24 (add legacyPluginToast)
- Tool Guard: 12 -> 14 (add bashFileReadGuard, readImageResizer,
  todoDescriptionOverride, webfetchRedirectGuard)
- Transform: 4 -> 5 (add toolPairValidator)
- Remove deleted dirs: anthropic-image-context, beast-mode-system
- Add new dirs: legacy-plugin-toast, todo-description-override,
  tool-pair-validator, webfetch-redirect-guard
2026-04-05 14:12:30 +09:00