Fallback to script parsing if prompt wasn't available through hooks#705
Fallback to script parsing if prompt wasn't available through hooks#705
Conversation
Entire-Checkpoint: d5e5d586fcac
PR SummaryMedium Risk Overview On Factory AI Droid implements Written by Cursor Bugbot for commit 8fa1853. Configure here. |
There was a problem hiding this comment.
Pull request overview
This PR addresses missing prompt capture for agents (notably Factory AI Droid in exec mode) by backfilling prompt.txt from the session transcript when hooks didn’t provide a prompt, ensuring stored session metadata contains the user prompt.
Changes:
- Add a new
agent.PromptExtractorinterface plusAsPromptExtractorcapability gating helper. - Backfill
prompt.txtduringTurnEndby extracting prompts from the transcript whenprompt.txtis absent/empty, and update session state accordingly. - Add lifecycle and capability tests covering prompt writing/backfill behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/entire/cli/lifecycle.go | Implements prompt.txt backfill from transcript on TurnEnd and updates session state after SaveStep. |
| cmd/entire/cli/lifecycle_test.go | Adds tests for prompt file writing, transcript backfill, and session-state update behavior. |
| cmd/entire/cli/agent/agent.go | Introduces the PromptExtractor interface for transcript-based prompt extraction. |
| cmd/entire/cli/agent/capabilities.go | Adds AsPromptExtractor helper that gates usage for capability-declaring agents. |
| cmd/entire/cli/agent/capabilities_test.go | Adds unit tests verifying AsPromptExtractor behavior for different agent types/cap declarations. |
| cmd/entire/cli/agent/factoryaidroid/lifecycle.go | Declares Factory AI Droid agent implements PromptExtractor. |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Entire-Checkpoint: af0f2abf5c4e

The E2E tests are currently failing for Factory AI Droid because the tests assumes an extracted prompt but using
droid execwill not triggerUserPromptSubmitwhich means we got no prompt. This meant so far an empty prompt was stored.If we now have no prompt.txt at the end of the turn we fallback to session transcript parsing to extract the prompt.