fix: forward event request context to agents#348
Closed
rpatel-scale wants to merge 1 commit into
Closed
Conversation
Contributor
Author
|
Closing this service change as superseded. The lineage supervisor fix is now agent-only: use the in-cluster EGP public backend URL () like research_report_agent, avoiding service changes for this POC. |
Contributor
Author
|
Closing this service change as superseded. The lineage supervisor fix is now agent-only: use the in-cluster EGP public backend URL via SGP_CLIENT_BASE_URL like research_report_agent, avoiding service changes for this POC. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
The lineage supervisor receives EVENT_SEND over Temporal and reads delegated credentials from SendEventParams.request. Agentex was sending the delegated credentials as HTTP headers to the pod, but serialized SendEventParams with request=None, so the workflow could not call /v5/builds with user credentials and hit 401.
Validation
Note: the full test_agent_acp_service.py file requires Docker/testcontainers locally; Docker is not available on this machine, so the full file could not complete here.
Greptile Summary
This PR fixes a 401 error in the lineage supervisor by forwarding the Agentex-generated delegated user headers into
SendEventParams.request.headersso that the Temporal workflow can read them when calling downstream APIs with user credentials.get_request_context_headersis extracted as a new synchronous method returning the safe subset of headers (filtered passthrough + delegation, excludingx-agent-api-key);get_headersnow delegates to it before adding auth headers on top.send_eventfix:params.requestis now populated with{"headers": request_context_headers}instead ofNone, making delegated credentials available to the serializedSendEventParamsthat Temporal reads.params.request.headersis present; a new isolated unit test (no Docker dependency) verifies agent auth key is kept out ofparams.requestwhile still reaching the agent pod as an HTTP header.Confidence Score: 4/5
Safe to merge; the fix is narrow and well-tested, credentials are correctly segregated between params and HTTP headers.
The logic is sound: x-agent-api-key stays out of params.request while delegation headers flow into both the JSON-RPC body and the HTTP headers. The only nit is that get_request_context_headers is computed twice inside send_event (once explicitly, once inside get_headers), which is wasteful but harmless since request state is immutable per call.
agentex/src/domain/services/agent_acp_service.py — the double-computation of context headers in send_event is worth a quick look.
Important Files Changed
Sequence Diagram
%%{init: {'theme': 'neutral'}}%% sequenceDiagram participant Caller participant AgentACPService participant get_request_context_headers participant get_headers participant AgentPod Caller->>AgentACPService: send_event(agent, event, task, request_headers) AgentACPService->>get_request_context_headers: filter passthrough + delegation headers get_request_context_headers-->>AgentACPService: request_context_headers (no agent-api-key) Note over AgentACPService: Build SendEventParams<br/>params.request.headers = request_context_headers AgentACPService->>get_headers: get_headers(agent, request_headers) Note over get_headers: re-calls get_request_context_headers internally get_headers-->>AgentACPService: request_context_headers + x-agent-api-key + x-request-id AgentACPService->>AgentPod: "POST /api (JSON-RPC EVENT_SEND)<br/>HTTP headers: delegation + x-agent-api-key<br/>params.request.headers: delegation only (no x-agent-api-key)"%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% sequenceDiagram participant Caller participant AgentACPService participant get_request_context_headers participant get_headers participant AgentPod Caller->>AgentACPService: send_event(agent, event, task, request_headers) AgentACPService->>get_request_context_headers: filter passthrough + delegation headers get_request_context_headers-->>AgentACPService: request_context_headers (no agent-api-key) Note over AgentACPService: Build SendEventParams<br/>params.request.headers = request_context_headers AgentACPService->>get_headers: get_headers(agent, request_headers) Note over get_headers: re-calls get_request_context_headers internally get_headers-->>AgentACPService: request_context_headers + x-agent-api-key + x-request-id AgentACPService->>AgentPod: "POST /api (JSON-RPC EVENT_SEND)<br/>HTTP headers: delegation + x-agent-api-key<br/>params.request.headers: delegation only (no x-agent-api-key)"Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix: forward event request context to ag..." | Re-trigger Greptile