Harness: StopRuntimeSession returns 200 but does not cancel the in-flight model call of InvokeHarness (billed up to maxTokens)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
Hướng nghiên cứu
Start with the InvokeHarness and StopRuntimeSession calls in the reproduction, then compare the observed stream and billing behavior with the Runtime docs cited in the issue. Determine whether cancellation, usage reporting, or documentation is the applicable fix; done means the stopped session behavior matches its documented contract or the harness documentation explicitly describes the limitation.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
For a managed harness, the only way to stop a session is StopRuntimeSession called with the harness ARN (the harness has no stop/cancel operation of its own; botocore 1.43.72 exposes only InvokeHarness on the data plane). The call returns 200, but the model call the harness already made keeps generating to the end, is billed in full (up to maxTokens), and the InvokeHarness stream keeps delivering text for minutes after the stop.
The Runtime docs (runtime-stop-session) say the operation "instantly terminates the specified session and stops any ongoing streaming responses". Nothing in the harness pages says a stop behaves differently for InvokeHarness, so either the behavior or the docs need a fix. We use the stop to implement a user-facing "Stop" button, so today a stopped answer costs the same as a finished one and nothing reports that cost back to the caller.
Steps to Reproduce
- Harness on the
DEFAULTendpoint, us-east-1, modelglobal.anthropic.claude-sonnet-5, no tools needed. Anafter_invocationlifecycle hook (Lambda) is configured. invoke_harness(harnessArn=..., qualifier="DEFAULT", runtimeSessionId=<new id>, messages=[{"role":"user","content":[{"text":"Write a ~3,000-word essay ... no tools"}]}], model={"bedrockModelConfig":{"modelId":"global.anthropic.claude-sonnet-5","maxTokens":8000}}, maxIterations=2, timeoutSeconds=600)and read the event stream.- At 10 s, from a second client:
stop_runtime_session(runtimeSessionId=<same id>, agentRuntimeArn=<harness ARN>, qualifier="DEFAULT"). - Keep reading the stream; then check Bedrock model invocation logging and the hook's logs.
Expected Behavior
As documented for StopRuntimeSession: the session ends and the ongoing streaming response stops right away, the in-flight model call is cancelled (so it is not billed to maxTokens), and ideally the after_invocation hook or a final metadata event reports the usage consumed up to the stop.
Actual Behavior
Measured on 2026-09-28, one run alone:
| t | event |
|---|---|
| 0 s | InvokeHarness; messageStart at 5.7 s |
| 10.7 s | StopRuntimeSession → 200 (0.61 s call) |
| 10.7 → 141.6 s | stream keeps delivering: 822 chars before the stop, 14,288 chars after it; it then breaks off with no contentBlockStop / messageStop / metadata |
- Bedrock model invocation logging shows one
ConverseStreamfrom the harness execution role for that session: input 6,588 tokens, output 8,000 tokens (the wholemaxTokens). Bedrock request id:8e41387b-1902-444e-a812-d71003f5d480. - The
after_invocationhook never fired for that session (checked 10 min later), so the caller has no way to learn the usage. - Closing the stream client-side without a stop does not cancel the generation either: in a separate run it went on to
end_turn(hook reported 6,592 in / 7,356 out, 94.5 s after the close). - In an earlier run a stop cut the stream only after ~38 s, and that one's hook reported
0/0usage withstopReason: "interrupted".
CLI Version
Not used for this. The calls are boto3 / botocore 1.43.72 (bedrock-agentcore). Filing here because this repo is where harness issues are tracked; please move it if another repo fits better.
Operating System
macOS
Additional Context
What would help, in order:
StopRuntimeSessionon a harness session cancels the in-flight model call (as the Runtime docs describe).- If cancellation isn't possible: the harness reports the usage of a stopped invocation (final
metadataevent orafter_invocationwith real token counts), so callers can account for it. - Otherwise, the harness docs state that a stop does not cancel the model call and that the call is billed to completion.
Workaround we use: the caller polls its own "stopped" state, closes the stream within ~2 s and discards the rest, and reconciles cost from Bedrock invocation logs.
- Ngôn ngữ chính
- TypeScript
- Star
- 339
- Fork
- 129
- Merge trung bình
- 19 giờ 21 phút
- Pull request đã merge (30 ngày)
- 125
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws/agentcore-cli
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
aws/agentcore-cli#2940 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
aws/agentcore-cli#2939 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
aws/agentcore-cli#2938 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
invoke: CUSTOM_JWT runtime errors discard the response body and error type (e.g. "Token has expired")Có thể đã có người làm @n1dhruv đã nhận 6 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
aws/agentcore-cli#2875 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
--debug has no effect; service error name, HTTP status and request ID never reach the terminalCó thể đã có người làm @abhiramshaji-cyber đã nhận 3 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
aws/agentcore-cli#2874 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của aws/agentcore-cli
Issue tương tự
-
manually bump balena-preload to ^19.0.6Có thể đã có người làm @shaunmulligan đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 66/100
balena-io/balena-cli#3200 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`MaterializedChatMessage._text` is quadratic in the number of text chunks (`+=` followed by `endsWith`), driving the extension host to heap OOMCó thể đã có người làm @olegius88 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
microsoft/vscode-prompt-tsx#205 ·
-
triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 64/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
melgarafael/DeskcommCRM#5340 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
ehmpathy/rhachet-roles-ehmpathy#1529 ·
Maintainer thường phản hồi trong vòng 1 ngày