Skip to content

fix(agent-proxy): stop logging client cancellations as proxy errors - #352

Merged
saifsmailbox98 merged 3 commits into
mainfrom
saif/bug-fixes-finn
Aug 4, 2026
Merged

fix(agent-proxy): stop logging client cancellations as proxy errors#352
saifsmailbox98 merged 3 commits into
mainfrom
saif/bug-fixes-finn

Conversation

@saifsmailbox98

@saifsmailbox98 saifsmailbox98 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description 📣

An agent hanging up mid-request was logged as a proxy error. Interrupting a prompt, or the agent exiting with calls in flight, cancels the request context and fails the round trip, which we classified as decision=error at ERROR level with a 502 nobody was left to receive. The agent owns the terminal the proxy logs to, so the line printed on top of whatever was being typed.

Cancellations now record as their own canceled decision at debug level: off the terminal, still in --log-file and --log-level debug. They report no status instead of a fabricated one and skip the error response write, since the client is already gone. The check is r.Context().Err() rather than matching on the error string, so only a client that actually went away is treated this way and genuine upstream failures stay error.

Docs PR: Infisical/infisical#7524

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

# Here's some code block to paste some code snippets

An agent hanging up mid-request, which happens on every interrupted
prompt and every exit with calls in flight, cancels the request context
and fails the round trip. That was classified as a proxy error, logged
at ERROR, and answered with a 502 nobody was left to receive. Since the
agent's TUI shares the terminal the proxy logs to, the line landed on
top of the user's input.

Cancellations now record their own decision at debug level, and report
no status rather than an invented one.
@infisical-review-police

Copy link
Copy Markdown

💬 Discussion in Slack: #pr-review-cli-352-fix-agent-proxy-stop-logging-client-cancellations-as-proxy-err

Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel.

@greptile-apps

greptile-apps Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR distinguishes downstream client cancellations from proxy failures so interrupted agent requests are logged at debug level without a fabricated HTTP status or an undeliverable 502 response.

  • Adds the canceled activity decision and debug-level mapping.
  • Returns early when the request context is canceled after forwarding fails.
  • Adds focused coverage for cancellation logging, status omission, and decision-level selection.

Confidence Score: 5/5

The PR appears safe to merge, with cancellation handling aligned to its stated logging and response semantics.

The changed branch is limited to failed forwards whose request context has already been canceled, still emits one activity record, and does not skip response-resource cleanup because forward errors return no response.

Important Files Changed

Filename Overview
packages/agentproxy/proxy.go Adds a narrowly scoped client-cancellation classification and conditionally omits the status field; no actionable defect was established.
packages/agentproxy/forward_test.go Adds an end-to-end client-abort test covering the canceled decision, non-error level, and absent response status.
packages/agentproxy/activitylog_test.go Extends decision-level coverage to assert that canceled activity is logged at debug level.

Reviews (1): Last reviewed commit: "fix(agent-proxy): stop logging client ca..." | Re-trigger Greptile

Comment thread packages/agentproxy/proxy.go Outdated
@veria-ai

veria-ai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

…angs up

A cancellation must not be able to erase what already happened. A
credential applied to the request stays brokered at info level, and a
refused host stays blocked at warn, so an agent cannot keep either out
of the activity log by disconnecting at the right moment.
@saifsmailbox98
saifsmailbox98 merged commit 29551f6 into main Aug 4, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants