Commit Graph

3041 Commits

Author SHA1 Message Date
ismeth
5dfe0a34fc fix(athena): enable retry and bound growth for agent-switch fallback markers
Delete marker from processedFallbackMessages on failure so message can be retried. Add MAX_PROCESSED_FALLBACK_MARKERS=500 with eviction to prevent unbounded Set growth.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-24 22:24:22 +09:00
ismeth
e8042fa445 fix(athena): harden council tool error handling and type safety
Improve not-configured error message with config file path. Wrap metadataFn in try/catch for best-effort metadata. Replace unsafe as-casts with getToolContextProperty helper. Show Name (model) format in errors. Return error directly for empty member selection.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-24 22:24:22 +09:00
ismeth
87487d8d25 fix(athena): add partial result tracking to session-waiter
Return CouncilSessionWaitResult with timedOut/aborted flags instead of raw array, so callers know when results are partial. Add 5 tests covering normal flow, abort, partial results, and edge cases.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-24 22:24:22 +09:00
ismeth
4da77be93f fix(athena): improve error extraction in council orchestrator
Replace String(result.reason) with proper instanceof Error check to produce clean error messages instead of [object Error] or full stack traces.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-24 22:24:22 +09:00
ismeth
750db54468 fix(athena): add permission restrictions to council-member agent
Add explicit tool denials (write, edit, task, call_omo_agent, athena_council) matching Oracle/Librarian pattern. Simplify static prompt to one-liner since council-prompt.ts provides full instructions.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-24 22:24:22 +09:00
ismeth
197dada95e fix(athena): enforce strict schema validation for council members
Add .strict() to CouncilMemberSchema to reject unknown fields like temperature. Remove unused Zod-inferred type exports. Add test verifying unknown fields are rejected.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-24 22:24:22 +09:00
ismeth
d8c988543f refactor(athena): remove dead session-guard code and unused types
Remove session-guard.ts (runtime gating uses hasPendingCouncilMembers instead), its test file, and dead snake_case type interfaces from types.ts that don't match the camelCase code.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-24 22:24:22 +09:00
ismeth
8381ea076a fix(prompts): normalize agent names for continuation injections 2026-02-24 22:24:22 +09:00
ismeth
21dc48e159 fix(agent-switch): make handoff durable and sync CLI TUI selection 2026-02-24 22:23:28 +09:00
ismeth
697c4c6341 fix(athena): parallelize council launches and gate handoff actions 2026-02-24 22:22:08 +09:00
ismeth
b0e2630db1 fix(athena): make council tool blocking — collect results directly instead of polling
The athena_council tool now waits for all council members to complete and
returns their collected results as markdown, eliminating the need for
Athena to repeatedly call background_output per member (which created
excessive UI noise).

- Add result-collector.ts that polls task status and fetches session content
- Update tool to accept BackgroundOutputClient and return formatted markdown
- Update Athena prompt to remove background_output polling steps
- Rewrite tests for new blocking behavior and markdown output format
2026-02-24 22:21:39 +09:00
ismeth
d908a712b9 feat(athena): make council member background tasks visible in UI
Council member tasks were launched via BackgroundManager but lacked the

ctx.metadata() call that links background sessions to the tool call in

the OpenCode TUI. Users couldn't click to inspect individual member outputs.

- Add session-waiter.ts to poll for session creation on launched tasks

- Call ctx.metadata() for each council member with sessionId linkage

- Matches the pattern used by delegate-task/background-task.ts

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-24 22:21:39 +09:00
ismeth
5a92c30f18 fix(athena): use getAgentConfigKey for keyword-detector Athena exclusion
The previous check used currentAgent?.toLowerCase() === 'athena' which failed

after display name remapping stored the agent as 'Athena (Council)' in session

state. Now uses getAgentConfigKey() to resolve display names back to config keys,

matching the established pattern used by other hooks (atlas, todo-continuation, etc.).

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-24 22:21:39 +09:00
ismeth
00051d6f19 test(athena): update tests and snapshots for council-member agent
- Add council-member to display names expected mappings

- Update model-requirements test: 11 → 12 builtin agents

- Regenerate model-fallback snapshots and JSON schema

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-24 22:21:39 +09:00
ismeth
597a9069bb feat(athena): add dedicated council-member agent for multi-model council
Replace oracle as the agent for council background tasks with a purpose-built

council-member agent. This avoids coupling to oracle's config/prompt and provides

proper read-only tool restrictions (deny write, edit, task, athena_council).

- New council-member-agent.ts with analysis-oriented system prompt

- Registered in agentSources (hidden from Sisyphus delegation table)

- Added to type system, Zod schemas, display names, tool restrictions

- Minimal model fallback (always overridden per council member at launch)

- Council orchestrator now launches members as council-member agent

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-24 22:21:39 +09:00
ismeth
46c26f9ff5 fix(athena): remove explicit name property causing agent resolution failure
Athena was the only agent setting name explicitly. The mismatch between

the name property ('Athena (Council Orchestrator)') and the config key

('Athena (Council)') caused TypeError during agent resolution.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-02-24 22:21:39 +09:00
ismeth
041e209882 test(athena): add athena to core agent display name remapping test 2026-02-24 22:21:39 +09:00
ismeth
e111e058b5 feat(athena): add Athena (Council) to agent display names
Aligns with upstream display name system added for all core agents.
2026-02-24 22:21:39 +09:00
ismeth
871ca9e201 feat(athena): add display name 'Athena (Council Orchestrator)' 2026-02-24 22:21:39 +09:00
ismeth
13692c63d1 fix(athena): remove dead temperature/permission fields from council launch pipeline
LaunchInput.temperature and LaunchInput.permission were accepted and
passed through the council orchestrator but never forwarded to the
actual promptAsync API call (SDK doesn't support per-request temperature
or permission). Remove the dead fields, the unused AthenaConfig
interface, and update tests/docs/schema accordingly.
2026-02-24 22:21:39 +09:00
ismeth
189bf89dc6 chore: regenerate JSON schema after rebase onto upstream dev 2026-02-24 22:20:54 +09:00
ismeth
dc4041c050 fix(athena): deny athena_council tool for council members as defense-in-depth
Already denied via agent-tool-restrictions.ts for all athena sessions,
but now also explicitly denied in the per-launch permission to make
the anti-recursion intent clear at the launch site.
2026-02-24 22:20:54 +09:00
ismeth
4d675bac89 refactor(athena): remove dead code from phases 2, 3, 5 pipeline
Remove 9 files (913 lines) from the code-driven synthesis pipeline that
was superseded by the agent-driven approach in phases 6-8.

Phases 3/5 built: collectCouncilResults → formatForSynthesis →
buildSynthesisPrompt → formatFindingsForUser → buildDelegationPrompt.

Phases 6-8 replaced with: launch → background_output → Athena
synthesizes in conversation → switch_agent. The old pipeline was
never wired into runtime and all consumers were other dead code.

Also simplifies executeCouncil to return CouncilLaunchResult (task IDs
+ failures) instead of reading stale task status via collectCouncilResults.

Deleted: council-result-collector, synthesis-types, synthesis-prompt,
synthesis-formatter, findings-presenter, delegation-prompts (+ 4 tests).
Cleaned: CouncilMemberStatus, AgreementLevel, CouncilMemberResponse,
CouncilExecutionResult types from types.ts.
2026-02-24 22:20:54 +09:00
ismeth
d8ba9b1f0c fix(athena): address 6 council review findings — launcher, schema, filtering, presentation
- Forward temperature and permission through council-launcher to background manager
- Add LaunchInput.temperature and LaunchInput.permission to background-agent types
- Extract session guard with 5-minute timeout to prevent stale council locks
- Make council optional in AthenaOverrideConfigSchema for partial user overrides
- Support member lookup by both name and model ID in filterCouncilMembers
- Add provider/model-id format validation to CouncilMemberSchema
- Fix findings-presenter group header to show finding count instead of first finding's reporter count
2026-02-24 22:20:54 +09:00
ismeth
7cfdc68100 feat(athena): update council member candidates with upgraded models
- Claude sonnet → opus 4.6, GPT 5.2 → 5.3 codex, Gemini flash → pro preview
- Replace copilot/opencode-zen candidates with kimi-for-coding/k2p5
- Update test cases and regenerate model-fallback snapshots
- All 2688 tests pass, typecheck clean
2026-02-24 22:20:54 +09:00
ismeth
628c9a8958 feat(installer): auto-configure athena council members based on available providers
The installer now detects which providers the user has (Anthropic, OpenAI,
Google, Copilot, OpenCode Zen) and generates council member config for Athena.
Requires at least 2 distinct providers; skips council config otherwise.
This implements the documented claim in configurations.md.
2026-02-24 22:20:54 +09:00
ismeth
5a72f21fc8 refactor(athena): rename session_handoff to switch_agent to avoid confusion with /handoff command
Rename across all layers to eliminate naming ambiguity:
- Tool: session_handoff → switch_agent
- Hook: agent-handoff → agent-switch
- Feature: agent-handoff/ → agent-switch/
- Types: SessionHandoffArgs → SwitchAgentArgs, PendingHandoff → PendingSwitch
- Functions: setPendingHandoff → setPendingSwitch, consumePendingHandoff → consumePendingSwitch

/handoff = inter-session context summary (existing command)
switch_agent = intra-session active agent change (our new tool)
2026-02-24 22:20:54 +09:00
ismeth
7a71d4fb4f feat(athena): add session handoff with Question tool for Atlas/Prometheus routing
After Athena synthesizes council findings, presents user with Question tool
TUI to choose: Atlas (fix now), Prometheus (create plan), or no action.
On selection, session_handoff tool stores intent + calls updateSessionAgent(),
then agent-handoff hook fires on session.idle to switch the main session's
active agent via promptAsync with synthesis context.
2026-02-24 22:20:01 +09:00
ismeth
fea732a6d2 docs(09-01): add Athena config and README listing 2026-02-24 22:18:31 +09:00
ismeth
ca4d844a17 feat(08-01): guide athena to collect member outputs
- update Athena workflow to launch council then call background_output per task

- require collecting all member responses before synthesis and delegation
2026-02-24 22:17:19 +09:00
ismeth
5816cdddc6 feat(08-01): return council task ids without blocking
- make athena_council launch-only and remove internal polling/formatting

- return JSON payload with running task mappings and launch failures

- update tool tests for task-id visibility, filtering, failure reporting, and dedup
2026-02-24 22:17:19 +09:00
ismeth
9a69478d8e feat(athena): use Question tool TUI for council member selection with dynamic member list 2026-02-24 22:17:19 +09:00
ismeth
a43d2bd98f fix(athena): ask user which council members to consult before calling tool 2026-02-24 22:17:19 +09:00
ismeth
cfba6f188b feat(07-01): document targeted council member selection
- describe optional members array in athena_council tool documentation

- guide Athena prompt to pass members only when user requests specific models
2026-02-24 22:17:19 +09:00
ismeth
f0f518f9cd feat(07-01): add optional council member filtering
- add optional members arg support to athena_council tool

- filter selected members case-insensitively with clear unknown-member errors

- add tests for default-all and member selection behavior
2026-02-24 22:17:19 +09:00
ismeth
d76c2bd8fa fix(tests): update model-requirements test for 11 builtin agents (add athena) 2026-02-24 22:17:19 +09:00
ismeth
f482b1b589 fix(athena): prometheus handoff via agent switch, not background task
Prometheus needs to interview the user interactively, so it can't run as a
background task. Updated Athena's delegation prompt:
- Atlas: still delegates via task tool (autonomous execution)
- Prometheus: outputs structured findings summary and tells the user to
  switch to Prometheus agent, which sees the conversation context and
  can ask clarifying questions directly
2026-02-24 22:17:19 +09:00
ismeth
1c1d09d858 fix(athena): prevent recursive council explosion — deny tool for bg tasks + dedup guard
Council members launched as agent='athena' got Athena's system prompt saying
'ALWAYS call athena_council first', plus the tool wasn't denied for bg athena
tasks. Each council member spawned 4 more → exponential explosion (47+ tasks).

Three fixes:
1. Deny athena_council in ATHENA_RESTRICTIONS (agent-tool-restrictions.ts)
   - Only affects background athena tasks (task-starter.ts)
   - Primary Athena (user-selected) still has access via permission field
2. Session-level dedup guard prevents re-calling while council is running
   - If Athena retries during long wait, returns 'already running'
3. Increase wait timeout from 2min to 10min (council members need time
   for real code analysis with Read/Grep/LSP)
2026-02-24 22:17:19 +09:00
ismeth
43ea49e523 fix(athena): force council-first behavior — unconditional prompt + skip keyword injection
The old prompt said 'when requiring multi-model analysis' which let Athena
decide to skip the council and do direct analysis herself. Combined with
keyword-detector injecting [search-mode] telling her to 'launch explore
agents and use Grep directly', Athena never called athena_council.

Two fixes:
1. System prompt now unconditionally requires athena_council as FIRST action
   - Explicitly prohibits Read/Grep/Glob/LSP/call_omo_agent
   - Identity is 'orchestrator, not analyst'
2. keyword-detector skips ALL injections for Athena agent
   - search/analyze/ultrawork modes conflict with council orchestration
   - Same pattern as isPlannerAgent() skip for Prometheus
2026-02-24 22:17:19 +09:00
ismeth
b663c464bc feat(06-01): direct athena prompt to athena_council
- replace manual council fan-out guidance with athena_council execution flow

- enforce athena_council-only constraint before confirmation-gated delegation
2026-02-24 22:17:19 +09:00
ismeth
4b0838b30e feat(06-01): register athena council tool in runtime registry
- export createAthenaCouncilTool from tools index

- wire athena_council with agents.athena.council config in tool registry
2026-02-24 22:17:19 +09:00
ismeth
362f446b46 feat(06-01): add athena council execution tool
- add athena_council tool scaffolding and runtime execution bridge

- poll background tasks before returning synthesized council output
2026-02-24 22:17:19 +09:00
ismeth
5ef5a5ac4d feat(05-02): add confirmation-gated Athena delegation prompt 2026-02-24 22:17:19 +09:00
ismeth
f408d44063 feat(05-02): allow Athena task tool delegation 2026-02-24 22:17:19 +09:00
ismeth
29afaf527c feat(05-01): add Atlas and Prometheus delegation prompt builders
- Build pure prompt constructors with confirmed finding context and agreement levels

- Add BDD tests for fix/planning intent, question context, and single-finding edge cases
2026-02-24 22:17:19 +09:00
ismeth
665499a40d feat(05-01): add synthesized findings presenter
- Format synthesis findings by agreement level for user-facing output

- Add BDD tests for ordering, warning flags, empty state, and recommendations
2026-02-24 22:17:19 +09:00
ismeth
b1f43e8113 test(04-01): add Athena registration and schema regressions
- verify Athena primary agents honor uiSelectedModel and override precedence

- add schema tests to lock athena acceptance in builtin and overridable names
2026-02-24 22:17:19 +09:00
ismeth
c1fab24b46 feat(04-01): register Athena in builtin agent resolution maps
- add Athena factory and prompt metadata to builtin agent sources

- define Athena fallback chain in AGENT_MODEL_REQUIREMENTS for primary resolution
2026-02-24 22:17:19 +09:00
ismeth
446901d7aa feat(04-01): add Athena primary agent factory and exports
- implement createAthenaAgent with primary-mode model behavior and prompt metadata

- export Athena factory and metadata through athena and root agent barrels
2026-02-24 22:17:19 +09:00
ismeth
95f133ff63 feat(03-01): implement synthesis contracts and formatter pipeline
- Add synthesis result contracts with agreement, provenance, and Athena assessment fields\n- Add synthesis prompt builder and council-response formatter with failure-aware provenance output
2026-02-24 22:16:45 +09:00