Inject OAuth access token into agent sessions + replace echo signals with curl + wire auto-advancement#77
Open
olsonjeffery wants to merge 3 commits into
Open
Conversation
…with curl - Add in-memory access_token cache (Arc<Mutex<HashMap<Uuid,String>>>) to AppState - Populate cache on startup refresh and POST /api/auth/refresh - Broadcast "agent token refreshed" to active WS topics on refresh - Extend build_context_prompt() with OFM_HOST/PORT/PID/ACCESS_TOKEN env vars - Add "OFM Environment" section with curl instruction table to agent prompts - Extract start_next_agent() shared function in orchestration/mod.rs - Refactor post_create_agent_run() to use shared function - Wire auto-advancement: completion_handler callers now invoke start_next_agent() on StartAgent - Reset run status to running in send_message() to prevent short-circuit - Update phase templates: replace echo signals with curl POST commands - Update spec/SPEC.md, spec/core/orchestration-loop.md, ARCHITECTURE.md - Fix all clippy warnings across the codebase
… prompt
- Security: OAuth access token is no longer embedded in prompt text
sent to LLM providers (was HIGH severity vulnerability)
- Security: Token no longer persisted in conversation transcript
- Security: Token no longer returned in GET /api/tasks/{id} response
- Token is written to .ofm_token in the worktree root (0600 permissions)
- Templates updated to read token via $(cat .ofm_token)
- Simplified access_tokens init in test files (removed fully-qualified paths)
- Replaced writeln!().ok() with let _ = writeln!() in config.rs
…ext prompt - ARCHITECTURE.md: reflect token written to .ofm_token, not embedded in prompt - spec/SPEC.md: document .ofm_token file approach with curl examples - spec/core/orchestration-loop.md: update agent flag endpoint invocation docs - src/archive/mod.rs: add .gitignore reminder in OFM Environment section - .gitignore: add .ofm_token to prevent accidental commits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR injects OAuth access tokens into agent LLM sessions, replaces echo-based signal stubs with actual curl commands to the OFM server's agent-flag endpoints, and wires up auto-advancement through the orchestration phases.
Key Changes
Phase 1: In-memory access_token cache
access_tokens: Arc<Mutex<HashMap<Uuid, String>>>toAppStatePOST /api/auth/refreshhandlerPhase 2: OFM env vars + curl instructions in context prompt
build_context_prompt()to accept host/port/pid/access_tokenOFM_HOST,OFM_PORT,OFM_PID,OFM_TASK_ID) and curl instruction tablePhase 3-4: Shared agent-starting function + token wiring
start_next_agent()shared function inorchestration/mod.rspost_create_agent_run()to use it.ofm_tokenfilePhase 5: Template updates
planification.md,implementation.md,review.md,pr.mdcurlcommands targetingPOST /api/tasks/{id}/agent-flags/{action}Phase 6: Run status reset on resume
send_message(), resettask_agent_runsfromcompleted/failedtorunningbefore resuming turnPhase 7: Auto-advancement wiring
agent_runs.rsandconversations.rsbroadcast tasks now handlecompletion_handler'sStartAgentresponse to callstart_next_agent()Phase 8: Token refresh broadcasting
"agent token refreshed"UserText to active WS topicsPhase 10: Security hardening
.ofm_tokenfile instead of embedding in prompt text (avoids leaking to LLM provider)GET /api/tasks/{id}response.ofm_tokenadded to.gitignorewith instructions in context prompt$(cat .ofm_token)instead of$OFM_ACCESS_TOKENDocumentation
spec/SPEC.md,spec/core/orchestration-loop.md,ARCHITECTURE.mdTesting