Repository navigation
Engineer mode: name the run it works on, /engineer to pick it, keep each run's cost - #178
Conversation
…k it, keep each run's cost
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e81a276a76
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if st.mode == "engineer" and not st.engineer_chosen: | ||
| run = self.cli.latest_capture() | ||
| st.engineer_target = (run["run_id"], str(run.get("prompt") or "")) if run else None |
There was a problem hiding this comment.
Refresh the default engineer target when a capture finishes
If the user switches to engineer mode while an agent run is still capturing, find_target() selects the previous run because the new HAR does not exist yet. When the capture finishes, finish() never refreshes this selection, and start() explicitly passes the stale target to engineer_from_prompt(). Consequently, the next engineer prompt modifies the previous client's run rather than the latest capture, even though no target was explicitly chosen. Refresh the unchosen target after capture completion, before starting any queued engineer prompt.
Useful? React with 👍 / 👎.
| if st.mode == "engineer" and not st.engineer_chosen: | ||
| run = self.cli.latest_capture() | ||
| st.engineer_target = (run["run_id"], str(run.get("prompt") or "")) if run else None |
There was a problem hiding this comment.
Engineer targets the previous capture
If the user switches to engineer mode while a new agent run is still capturing, find_target() selects the previous run because the new HAR does not exist yet. Nothing refreshes that choice when capture finishes. After /new, the next engineer prompt still changes the previous run's client instead of the latest capture's. Refresh the default target after capture finishes.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/reverse_api/repl/app.py
Line: 365-367
Comment:
**Engineer targets the previous capture**
If the user switches to engineer mode while a new agent run is still capturing, `find_target()` selects the previous run because the new HAR does not exist yet. Nothing refreshes that choice when capture finishes. After `/new`, the next engineer prompt still changes the previous run's client instead of the latest capture's. Refresh the default target after capture finishes.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| sdk=sdk, | ||
| output_mode=output_mode, | ||
| usage=_run_totals(resume.get("usage") or {}, usage) if resume else usage, | ||
| usage=_run_totals(spent_before, usage), |
There was a problem hiding this comment.
Older history entries can store spending only in cost or total_cost. _run_totals() adds only matching keys, while recorded_cost() prefers estimated_cost_usd. An old cost: 0.50 plus a new estimated_cost_usd: 0.25 therefore displays $0.25 rather than $0.75. Normalize the old cost before adding the new cost so these saved runs retain their capture spending.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/reverse_api/cli.py
Line: 1760
Comment:
**Older capture costs disappear**
Older history entries can store spending only in `cost` or `total_cost`. `_run_totals()` adds only matching keys, while `recorded_cost()` prefers `estimated_cost_usd`. An old `cost: 0.50` plus a new `estimated_cost_usd: 0.25` therefore displays $0.25 rather than $0.75. Normalize the old cost before adding the new cost so these saved runs retain their capture spending.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.# Conflicts: # CHANGELOG.md
Stacked on #174.
Why
In engineer mode you could not tell which run your prompt would change, or how to pick another one: text silently went to the latest run. Costs were also off: re-engineering a run replaced its recorded cost with the last re-engineer's, and the client card showed the session's spend next to the run's own tokens.
What
/engineer [run_id]picks another run among those with a HAR. A choice holds until another run is engineered or a new agent run captures one./historyopened while a run wraps up waits for it, so it lists the new cost.Verification
/engineer, the subcommand's run, the prompt routing, the cost sum on a real history file, the card cost and the wait. ruff and mypy are clean, and 1310 tests pass.Out of scope
Summary by cubic
Engineer mode now names the run it works on, lets you pick a different one with
/engineer, and a re-engineered run keeps the full cost of all its passes./engineer [run_id]picks another run among those with a HAR; the choice holds until another run is engineered or a new agent run captures one./historyopened while a run wraps up waits for it, so it lists the new cost.Written for commit 151a6bf. Summary will update on new commits.
Refresh the default engineer target after capture before merging so later prompts do not change an older run.
Findings
Fix with agent prompt
Summary
Engineer mode now names its target and adds
/engineerto choose another saved capture.Reviews (1) · Last reviewed commit: "feat(engineer): name the run engineer mo..." · Reviewed by Greptile