Skip to content

Add --fake flag for e2e test session replay#1061

Merged
dgageot merged 1 commit intodocker:mainfrom
stanislavHamara:fake-flag-for-e2e-session-replay
Dec 11, 2025
Merged

Add --fake flag for e2e test session replay#1061
dgageot merged 1 commit intodocker:mainfrom
stanislavHamara:fake-flag-for-e2e-session-replay

Conversation

@stanislavHamara
Copy link
Copy Markdown
Contributor

Summary

  • Add --fake <cassette-path> flag to replay recorded AI responses for E2E testing
  • Extract VCR proxy logic into reusable pkg/fake package
  • Refactor e2e/proxy_test.go to use shared code, removing ~110 lines of duplication

Test plan

  • Build passes (task build)
  • Lint passes (task lint)
  • Manual test with curl (see below)
  • E2E tests pass (task test)

Manual testing

Terminal 1 - Start server with fake mode:

./bin/cagent api \
  --fake ./e2e/testdata/cassettes/TestExec_OpenAI \
  --listen :8080 \
  --session-db /tmp/test-session.db \
  ./e2e/testdata/basic.yaml

**Terminal 2 - Test normal endpoints and AI replay:

# Create session and send message
SESSION_ID=$(curl -s -X POST http://localhost:8080/api/sessions \
  -H "Content-Type: application/json" -d '{}' | jq -r '.id')

curl -N "http://localhost:8080/api/sessions/${SESSION_ID}/agent/basic.yaml" \
  -H "Content-Type: application/json" \
  -d '[{"role": "user", "content": "What'\''s 2+2?"}]'

**Expected output (replayed from cassette, no real API call):

data: {"type":"agent_info","agent_name":"root","model":"openai/gpt-3.5-turbo","description":"A helpful AI assistant"}
data: {"type":"stream_started","session_id":"...","agent_name":"root"}
data: {"type":"agent_choice","content":"2","agent_name":"root"}
data: {"type":"agent_choice","content":" +","agent_name":"root"}
data: {"type":"agent_choice","content":" ","agent_name":"root"}
data: {"type":"agent_choice","content":"2","agent_name":"root"}
data: {"type":"agent_choice","content":" equals","agent_name":"root"}
data: {"type":"agent_choice","content":" ","agent_name":"root"}
data: {"type":"agent_choice","content":"4","agent_name":"root"}
data: {"type":"agent_choice","content":".","agent_name":"root"}
data: {"type":"stream_stopped","session_id":"...","agent_name":"root"}

@stanislavHamara stanislavHamara requested a review from a team as a code owner December 11, 2025 09:21
@dgageot dgageot merged commit 20b398a into docker:main Dec 11, 2025
5 checks passed
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.

2 participants