Skip to content

feat(chat): agent self-execute with optional result injection (#264) - #334

Merged
vybe merged 1 commit into
mainfrom
feature/264-self-execute
Apr 14, 2026
Merged

vybe merged 1 commit into
mainfrom
feature/264-self-execute

Conversation

@vybe

@vybe vybe commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds SELF_TASK activity type for tracking agent self-execute background tasks
  • Implements inject_result parameter to surface task results as collapsible chat messages
  • Validates X-Source-Agent header against MCP key scope to prevent header spoofing

Changes

  • src/backend/models.py - Added SELF_TASK enum, inject_result param
  • src/backend/routers/chat.py - Self-task detection, security validation, result injection
  • src/mcp-server/src/tools/chat.ts - Added inject_result, chat_session_id params
  • src/mcp-server/src/client.ts - Updated options interface
  • src/frontend/src/components/chat/ChatBubble.vue - Collapsible purple-styled self-task results
  • src/frontend/src/stores/network.js - Added self_task to activity filter
  • tests/test_self_execute.py - 21 unit tests for detection, security, injection logic
  • docs/memory/feature-flows/self-execute.md - Feature flow documentation

Test Plan

  • New tests pass: pytest tests/test_self_execute.py -v (21 passed)
  • Manual verification: agent calls chat_with_agent(self, parallel=true, inject_result=true)
  • Verify self-task appears in activity panel with correct type
  • Verify result injection renders as collapsible purple bubble in chat

Closes #264

🤖 Generated with Claude Code

Allow agents to trigger background tasks on themselves during chat via
`chat_with_agent(agent_name=<self>, parallel=true)`. New `inject_result`
parameter optionally surfaces the result as a styled message in the
originating chat session.

Backend:
- Add SELF_TASK activity type for distinct tracking
- Detect self-calls when x_source_agent == target name
- Security: validate X-Source-Agent matches MCP key scope
- Result injection into chat_messages with source='self_task'
- WebSocket events for self-task start/completion

MCP:
- Add inject_result and chat_session_id params to chat_with_agent
- Self-call detection and logging

Frontend:
- Self-task in activity types query (network store)
- ChatBubble: collapsible purple-styled self-task results

Tests: 21 unit tests covering detection, validation, injection logic

Closes #264

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@vybe
vybe merged commit 63fa488 into main Apr 14, 2026
vybe added a commit that referenced this pull request Apr 14, 2026
Sprint C now 3/5 complete. Next: #294 (validation).

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

feat: Agent self-execute — background task execution during chat (SELF-EXEC-001)

1 participant