-
Notifications
You must be signed in to change notification settings - Fork 26
fix: cancellation turn-granularity, extension report gaps, and cache-aware cost pricing #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b6362ed
f0a92a1
c481c02
a14c581
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -209,6 +209,17 @@ export async function runAllBrowser( | |
| pushPartialResult(stopReason); | ||
| break evaluatorLoop; | ||
| } | ||
| // The extension's DomTarget throws a plain Error tagged `code: "OPFOR_STOP"` | ||
| // on user cancel/pause (see runners/extension/domTarget.js) — core can't | ||
| // import that class, so recognize it structurally instead. Without this, | ||
| // a user-cancelled run threw past every handler below and returned no | ||
| // report at all, silently dropping the TokenTracker totals collected so far. | ||
| if ((err as { code?: string })?.code === "OPFOR_STOP") { | ||
| stopReason = err instanceof Error ? err.message : "Run stopped by user."; | ||
| notify({ type: "run_stopped", reason: stopReason }); | ||
| pushPartialResult(stopReason); | ||
| break evaluatorLoop; | ||
| } | ||
|
Comment on lines
+217
to
+222
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
ast-grep outline runners/extension/orchestrator.js --items all
rg -n -C 6 'run_stopped|onProgress|broadcastProgress|setRunStatus|finalizeUserInterruption' \
runners/extension/orchestrator.jsRepository: KeyValueSoftwareSystems/agent-opfor Length of output: 12727 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "## runAllBrowser relevant section"
sed -n '180,235p' core/src/execute/runAllBrowser.ts
echo
echo "## extension run_stopped occurrences"
rg -n -C 8 'run_stopped|OPFOR_STOP|type === "attack_done"|emit\(|create.*Run|runAll\(' .
echo
echo "## executeAdaptiveRedTeamRun message send around stop"
sed -n '840,905p' runners/extension/orchestrator.jsRepository: KeyValueSoftwareSystems/agent-opfor Length of output: 50394 Forward
🤖 Prompt for AI Agents |
||
| throw err; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Anthropic cache write multipliers 1.25x 2x pricing💡 Result:
Anthropic's prompt caching pricing is structured around a "write premium" paid when content is first stored, followed by a significant discount on subsequent reads [1][2]. These multipliers are applied relative to the model's base input token price [1][3]. The pricing multipliers for prompt caching are as follows: * 5-Minute Cache Write: 1.25x the base input price [1][2]. This tier keeps the cache valid for 5 minutes [1][3]. * 1-Hour Cache Write: 2x the base input price [1][2]. This tier keeps the cache valid for 1 hour [1][3]. * Cache Read (Hit): 0.1x the base input price [1][2]. This provides a 90% discount on standard input costs for any content retrieved from the cache [4][2]. Because cache reads cost only 10% of the standard input price, prompt caching generally becomes cost-effective after a small number of hits [1][4]. For the 5-minute cache (1.25x write), the investment is typically recovered after just one cache read [1][2]. For the 1-hour cache (2x write), it typically takes two cache reads to break even [1][2]. These multipliers stack with other pricing modifiers, such as the Batch API discount and data residency adjustments [3][5].
Citations:
🌐 Web query:
Anthropic pricing cache read 90% discount cache write multiplier💡 Result:
Anthropic’s prompt caching pricing is based on a system of multipliers applied to the base input token rate [1][2][3]. Cache reads are charged at 0.1x (10%) of the base input price, effectively providing a 90% discount on those tokens compared to standard, uncached input [1][4][3]. Cache writes involve a premium because the content must be stored [1][2][5]. There are two tiers for cache writes, each with a different multiplier relative to the base input rate: 5-Minute Cache Write: 1.25x the base input price [1][6][3]. This tier is valid for 5 minutes and is generally more cost-effective for bursty or high-frequency interactions [3][5]. 1-Hour Cache Write: 2x the base input price [1][2][3]. This tier is valid for 1 hour and is intended for longer-running workflows where the cached content will be reused multiple times [4][3][5]. Because cache hits cost only 10% of the standard input rate, the upfront write premium is typically recovered quickly: the 5-minute cache write generally pays for itself after a single cache read, while the 1-hour cache write typically breaks even after two cache reads [1][2][4][3].
Citations:
🏁 Script executed:
Repository: KeyValueSoftwareSystems/agent-opfor
Length of output: 2672
Distinguish cache reads from cache writes.
Line 127 says cached input is “often ~100× cheaper than fresh text,” but that describes cache reads. Cache writes can be pricier than fresh input, including Anthropic’s 5-minute cache-write rate at 1.25× base input pricing and the 1-hour cache-write rate at 2× base input pricing. Update this to describe cache-read and cache-write rates separately.
Proposed documentation change
📝 Committable suggestion
🤖 Prompt for AI Agents