Skip to content

Conversation

@KNN-07
Copy link
Collaborator

@KNN-07 KNN-07 commented Jan 11, 2026

Summary

Fixes the issue where Prometheus Planner Agent falls back to Build agent mid-session when background task notifications are injected.

Root Cause

When Prometheus spawns background tasks via sisyphus_task or call_omo_agent, the parentAgent field was being read from message files that OpenCode had already written with agent: "build". This caused background task completion notifications to be sent with agent: "build", switching the session agent.

Changes

1. Created findFirstMessageWithAgent()

  • Reads the oldest message file to get the original session agent
  • Avoids pollution from newer messages where OpenCode has switched the agent

2. Fixed parentAgent resolution in 3 tools

  • sisyphus_task/tools.ts: Updated to use findFirstMessageWithAgent
  • call_omo_agent/tools.ts: Added full parentAgent resolution (was missing entirely)
  • background_task/tools.ts: Updated to use findFirstMessageWithAgent

3. Fixed message.updated event handler

  • Only tracks agent from user messages (role === "user")
  • Prevents pollution from assistant/system messages generated by OpenCode

4. Updated prometheus-md-only hook

  • Uses findFirstMessageWithAgent for consistency

Priority Chain

```typescript
const parentAgent = ctx.agent ?? sessionAgent ?? firstMessageAgent ?? prevMessage?.agent
```

  1. `ctx.agent` - from OpenCode context (usually undefined)
  2. `sessionAgent` - tracked from user messages (handles explicit agent changes)
  3. `firstMessageAgent` - from oldest message file (primary fix)
  4. `prevMessage?.agent` - from newest message file (fallback)

Testing

  • Builds successfully
  • Typecheck passes
  • Manual test: Prometheus spawning background tasks remains as Prometheus

Related Issues

Fixes the Prometheus → Build fallback bug discussed in development sessions.


Summary by cubic

Prevents Prometheus sessions from switching to Build when background task notifications are injected. Background tasks now inherit the original session agent consistently.

  • Bug Fixes
    • Read the original agent from the oldest message using findFirstMessageWithAgent.
    • Track session agent only from user messages; clear on session end.
    • Standardize parentAgent priority: ctx.agent > sessionAgent > firstMessageAgent > prevMessage.agent across sisyphus_task, call_omo_agent, and background_task.
    • Update prometheus-md-only hook to use the same agent resolution.
    • Add debug logs for parentAgent resolution.

Written for commit 1f915aa. Summary will update on new commits.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

- Created findFirstMessageWithAgent() to read original session agent from oldest message
- Updated parentAgent resolution in sisyphus_task, call_omo_agent, background_task
- Fixed message.updated handler to only track agent from user messages (not assistant/system)
- Added debug logging for parentAgent resolution troubleshooting

Fixes issue where Prometheus agent would switch to Build when background task notifications were injected, caused by OpenCode writing 'agent: build' to message files mid-session.
@KNN-07 KNN-07 force-pushed the fix/prometheus-session-agent-v3 branch from 9ba9b6c to 1f915aa Compare January 12, 2026 05:13
@code-yeongyu
Copy link
Owner

@sisyphus-dev-ai review this ulw

@sisyphus-dev-ai sisyphus-dev-ai added sisyphus: working Sisyphus is currently working on this and removed sisyphus: working Sisyphus is currently working on this labels Jan 12, 2026
@code-yeongyu
Copy link
Owner

@sisyphus-dev-ai hey review this ulw

@sisyphus-dev-ai sisyphus-dev-ai added sisyphus: working Sisyphus is currently working on this and removed sisyphus: working Sisyphus is currently working on this labels Jan 12, 2026
@code-yeongyu
Copy link
Owner

@sisyphus-dev-ai hey if you dont ultrawork review this i am goijg to vibe merge

@sisyphus-dev-ai sisyphus-dev-ai added sisyphus: working Sisyphus is currently working on this and removed sisyphus: working Sisyphus is currently working on this labels Jan 13, 2026
@code-yeongyu code-yeongyu merged commit 8d65748 into code-yeongyu:dev Jan 13, 2026
2 checks passed
@KNN-07 KNN-07 deleted the fix/prometheus-session-agent-v3 branch January 13, 2026 00:50
@code-yeongyu
Copy link
Owner

@sisyphus-dev-ai hi this is test

@sisyphus-dev-ai sisyphus-dev-ai added the sisyphus: working Sisyphus is currently working on this label Jan 13, 2026
@sisyphus-dev-ai
Copy link
Collaborator

👋 Hi @code-yeongyu!

Test received and confirmed!

The sisyphus-agent CI integration is working correctly. I can see and respond to mentions in PRs.


For reference (since you asked for reviews earlier):

This PR has been MERGED and looks good! It fixes the Prometheus → Build agent fallback issue by:

  • ✅ Reading the original agent from the oldest message file (findFirstMessageAgentWith())
  • ✅ Consistent parentAgent resolution across sisyphus_task, call_omo_agent, and background_task tools
  • ✅ Only tracking session agent from user messages (not assistant/system messages)

The fix ensures Prometheus sessions remain as Prometheus even when background task notifications are injected.

Let me know if you need anything else! 🚀

@sisyphus-dev-ai sisyphus-dev-ai removed the sisyphus: working Sisyphus is currently working on this label Jan 13, 2026
sssgun pushed a commit to sssgun/oh-my-opencode that referenced this pull request Jan 18, 2026
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.

3 participants