mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #428] [CLOSED] fix(observability): retain lifecycle metrics after caller cancellation #428
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#428
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/AgentENV/pull/428
Author: @guozy18
Created: 10/23/2026
Status: ❌ Closed
Base:
main← Head:sync/cancellation-safe-stage-metrics📝 Commits (1)
a425938fix: record sandbox stage metrics inside cancellation-safe orchestrator tasks📊 Changes
5 files changed (+151 additions, -39 deletions)
View changed files
📝
Cargo.lock(+1 -0)📝
Cargo.toml(+1 -0)📝
src/api/impls/sandbox.rs(+10 -30)📝
src/orchestrator/service.rs(+48 -9)📝
src/orchestrator/tests.rs(+91 -0)📄 Description
What
Record sandbox operation duration and in-flight metrics for the full lifetime of the cancellation-safe orchestrator task, including when an HTTP client disconnects before the operation finishes.
Why
The operation already survives request cancellation, but its timer lived in the HTTP handler. Dropping that handler prematurely decremented in-flight and lost the duration sample.
Related issue
No linked issue; focused lifecycle observability fix.
Scope and non-goals
Move create, fork, pause, resume and capture timers into the existing task boundary. Add delete, network-update and extension-parameter-patch stage metrics. Image resolution and snapshot publication timers stay with their existing request-owned work.
Design and behavior changes
run_cancellation_safe. Dropping the API handler or its result receiver does not drop that timer. Completion records the task's actualok/errorresult and releases its in-flight guard.agentenv_sandbox_stage_duration_secondsandagentenv_sandbox_stage_inflight) and existing operation/stage labels. Infer cold/warm create from the launch source. Remove the corresponding API timers so requests are not counted twice.ok, while individual failures stay in the response.Compatibility and operations
Validation
cargo fmt --all -- --checkcargo clippy --locked --workspace --all-targets --all-features -- -D warningsThe regression cancels a caller after pause begins, checks in-flight remains 1, and then checks one full-duration sample, the actual success/error label, in-flight 0, and final sandbox state. It runs against both successful and failed pauses with a thread-local recorder. The additional check used a separately built #428 server and daemon on upstream
9f62cbe, without #427 or fork/main. All 829 tracked source files were checked against the PR commit. Unrelated service and full OSS/P2P suites were not run.GitHub
unit-testsis currently blocked before running tests bytikv-jemalloc-sys: inheritedMAKEFLAGS=" -- PROFILE=debug -j ..."makes its nested make treat-jas a target. The identical failure is present on the unchanged upstream baseline and in this PR's job. This PR changes neither the Makefile nor that dependency version. The direct Cargo and isolated runtime results above are separate evidence, not a claim that all GitHub checks pass.Risks and reviewer notes
Metrics now include direct orchestrator callers and operations that outlive API handlers. Existing operation behavior and cancellation ownership are unchanged.
Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.