Commit Graph

30 Commits

Author SHA1 Message Date
YeonGyu-Kim
dd12928390 fix: resolve GitHub Actions workflow hang after task completion
- Add process.exit(0) in runner.ts for immediate termination
- Fix Timer type to ReturnType<typeof setInterval> in manager.ts
- Add .unref() to BackgroundManager polling interval
- Add cleanup() method to BackgroundManager

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-27 23:06:44 +09:00
Sisyphus
101299ebec fix: preserve model context across background agent handoffs (#229)
Fixes #191

This commit ensures that the user's selected model is preserved when
background tasks complete and notify their parent sessions.

Changes:
- Add parentModel field to BackgroundTask and LaunchInput interfaces
- Capture model context when launching background tasks
- Pass model context when notifying parent sessions after task completion

Impact:
- Users with OAuth providers (Google, Anthropic) will now have their
  model selection preserved across background task continuations
- Background agents no longer revert to hardcoded defaults

Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
2025-12-25 22:36:06 +09:00
YeonGyu-Kim
845a1d2a03 fix(background-agent): cancel all nested descendant tasks recursively (#107)
Previously, background_cancel(all=true) only cancelled direct child tasks, leaving grandchildren and deeper nested tasks uncancelled. This caused background agents to continue running even when their parent session was cancelled.

Changes:
- Added getAllDescendantTasks() method to BackgroundTaskManager for recursive task collection
- Updated background_cancel to use getAllDescendantTasks instead of getTasksByParentSession
- Added comprehensive test coverage for nested task cancellation scenarios

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-19 01:56:38 +09:00
YeonGyu-Kim
b984bfd9f3 fix(session-notification): skip notification for subagent sessions (#70)
- Import subagentSessions from claude-code-session-state in both manager.ts and session-notification.ts
- Add sessionID to subagentSessions Set when creating background task session
- Remove sessionID from subagentSessions when background task session is deleted
- Check if session is in subagentSessions before triggering notification

Fixes #70: Notification hook no longer triggers for subagent idle events

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-16 23:01:48 +09:00
YeonGyu-Kim
116a90db6a enhance(background-agent): Prevent recursive tool calls and wait for session todos before completion
- Remove call_omo_agent from blocked tools (only calls explore/librarian, safe)
- Keep task and background_task blocked to prevent recursion
- Add checkSessionTodos() to verify incomplete todos before marking tasks complete
- Update session.idle event handler to respect todo status
- Add polling check in task completion to wait for todo-continuation

🤖 Generated with assistance of OhMyOpenCode (https://github.com/code-yeongyu/oh-my-opencode)
2025-12-15 23:54:59 +09:00
YeonGyu-Kim
355fa35651 fix(hooks): respect previous message's agent mode in message sending hooks
Message hooks like todo-continuation-enforcer and background-notification
now preserve the agent mode from the previous message when sending follow-up
prompts. This ensures that continuation messages and task completion
notifications use the same agent that was active in the conversation.

- Export findNearestMessageWithFields and MESSAGE_STORAGE from hook-message-injector
- Add getMessageDir helper to locate session message directories
- Pass agent field to session.prompt in todo-continuation-enforcer
- Pass agent field to session.prompt in BackgroundManager.notifyParentSession

Closes #59

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-15 19:02:31 +09:00
YeonGyu-Kim
ed76c502c3 feat(background-agent): restrict tool access in subagent execution to prevent recursive calls
- Disable 'task' and 'call_omo_agent' tools in BackgroundManager
- Disable recursive background operation tools in call_omo_agent sync execution
- Prevents agents from spawning background tasks or calling themselves

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-14 14:00:28 +09:00
YeonGyu-Kim
d1a527c700 feat(background-agent): restrict tool access in subagent execution to prevent recursive calls
- Disable 'task' and 'call_omo_agent' tools in BackgroundManager
- Disable recursive background operation tools in call_omo_agent sync execution
- Prevents agents from spawning background tasks or calling themselves

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-14 11:54:36 +09:00
YeonGyu-Kim
b00b8238f4 fix(background-task): gracefully handle agent not found errors
When an invalid or unregistered agent is passed to background_task or
call_omo_agent, OpenCode crashes with "TypeError: undefined is not an
object (evaluating 'agent.name')". This fix:

- Validates agent parameter is not empty before launching
- Catches prompt errors and returns friendly error message
- Notifies parent session when background task fails
- Improves error message to guide user on resolution

Fixes #37

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-14 01:23:44 +09:00
YeonGyu-Kim
41a318df66 fix(background-task): send notification to parent session instead of main session
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 13:36:31 +09:00
YeonGyu-Kim
91ae0cc67d feat(background-task): show original prompt and last message in running task status
- Add prompt field to BackgroundTask to store original prompt
- Add lastMessage/lastMessageAt to TaskProgress for real-time monitoring
- Extract last assistant message during polling
- Update formatTaskStatus() to display prompt (truncated 300 chars) and
  last message (truncated 500 chars) with timestamp

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 13:26:25 +09:00
YeonGyu-Kim
12c0b7b6c0 refactor(omo-task): rename to call_omo_agent with run_in_background parameter
- Rename omo-task to call-omo-agent with mandatory run_in_background parameter
- Implement background mode using BackgroundManager (fire-and-forget abort)
- Implement sync mode with existing subagent logic
- Fix background_cancel: use fire-and-forget abort to prevent parent session interruption
- Add call_omo_agent to tool disable list in explore/librarian agents
- Add call_omo_agent to tool disable list in BackgroundManager

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
f6bdc45fe7 feat(background-task): disable tools in child sessions
Background task tool이 child session을 생성할 때 background_task, background_output, background_cancel 도구를 자동으로 비활성화합니다. OpenCode Task tool 패턴과 동일하게 무한 재귀 호출을 방지합니다.

- manager.ts: promptAsync 호출 시 tools 설정 추가
- index.ts: 불필요한 agent 레벨 disable 설정 제거 (manager에서 처리)
- notification: tool calls 카운트 제거 (정확하게 트래킹되지 않음)

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
01f935f074 refactor(background-task): unify background_result and background_status into background_output tool
- Merge background_status into background_output with block parameter
- Replace background_result references with background_output throughout codebase
- Update tool descriptions to reflect new unified API
- Remove background-tasks.json (memory-based only)
- Simplify notification messages and tool usage instructions
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
550322cb0c fix(background-agent): use promptAsync to avoid response parsing errors
session.prompt() fails due to response Zod validation.
promptAsync is fire-and-forget, no response parsing.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
14f785925c fix(background-agent): send notification to main session ID
TUI API sends to active session (could be subagent).
Use getMainSessionID() to explicitly target main session.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
6449a00f46 fix(background-agent): use TUI appendPrompt + submitPrompt for notification
session.prompt() fails with validation errors in background context.
Switch to TUI API which directly manipulates the main session input.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
3fd9e95579 fix(background-agent): simplify notification - remove status checks
Previous implementation had too many defensive checks that blocked
normal cases. Simplified to: Toast -> 200ms delay -> session.prompt()

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
78047dfd7d fix(background-agent): use session status check and prompt() for visible notification
- Replace promptAsync() with session.prompt() for visible TUI updates
- Add main session check to skip subagent sessions
- Add session status idle check before sending prompt
- Add 200ms debounce with re-check to prevent race conditions
- Fallback to pending queue when session is busy

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
9986841f9b fix(background-agent): force TUI update when notifying parent session
- Use `promptAsync` instead of `prompt` to avoid session state conflicts
- Use `tui.showToast` for immediate visible feedback
- Hack: Trigger `tui.submitPrompt` after message injection to force TUI refresh and trigger AI response
- Update `BackgroundManager` to accept `PluginInput` for directory access
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
b422e2f94f fix(background-agent): use session.prompt() instead of promptAsync()
prompt() waits for AI response, ensuring message is actually processed.
Added response logging to debug if message delivery works.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
e74cc82bcf fix(background-agent): use tui.showToast() for notification
promptAsync() doesn't show visible message to user.
Use tui.showToast() instead for immediate visible notification.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
ea46ba6c60 fix(background-agent): use session.idle event for completion detection
- Remove broken session.updated handler (Session has no status field)
- Add session.idle event handler for proper completion detection
- Remove all file persistence (persist/restore methods)
- Add comprehensive logging for debugging
- Dual detection: event-based (session.idle) + polling (session.status API)

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
d67f97158a fix(background-agent): use session.status() API for idle detection
session.get() doesn't return status field - it was always undefined.
Now using session.status() API which returns { type: 'idle' | 'busy' | 'retry' }

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
24a7f333a2 refactor(background-agent): remove file persistence, use memory-only
- Remove background_tasks.json persistence (race condition with multiple instances)
- Pure memory-based task management
- Add logging for promptAsync errors
- Remove unused persist/restore methods

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
80cfe87390 fix(background-agent): use promptAsync to wake parent session
- Change prompt() to promptAsync() for parent session notification
- Only mark 404 errors as permanent task failure
- Add defensive progress initialization

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
5733291a0f fix(background-agent): notify parent session when task completes
- Add notifyParentSession() to send message to parent session via prompt()
- Agent receives completion notification immediately, not waiting for next chat.message
- Includes task ID, description, duration, tool calls in notification

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
b5d56246f6 fix(background-agent): add polling mechanism for child session tracking
- Replace unreliable event-based tracking with 2-second polling
- Use SDK session.get() to detect completion (status === idle)
- Use SDK session.messages() to count tool_use parts for progress
- Auto-start polling on launch, auto-stop when no running tasks
- Resume polling on restore if running tasks exist

Fixes: Child session events not reaching plugin event handler

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
245acdabad fix(background-agent): address Oracle review feedback
- Remove unused storage.ts (dead code, runtime inconsistency)
- Change persist() to sync void (debounce semantics clarity)
- Add type guards in handleEvent() for event safety
- Remove unused 'pending' from BackgroundTaskStatus

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
698cdb6744 feat(background-agent): add BackgroundManager with persistence layer
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00