Repository navigation
mcpx(daemon): bound chat proxy upstream calls (#2114) #3380
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1f19f8c
chore: start queue task 3088
dezren39 a98c694
fix(mcpx): bound chat proxy upstream calls
dezren39 562db2a
docs(mcpx): change fragment for the new proxy configuration section (…
90bb132
docs(mcpx): register proxy-timeout change fragment in compendium mani…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| sections: proxy | ||
| kind: Added | ||
| summary: configuration.md gains the proxy section (#2114): the new proxy.timeout setting (duration, 10m default, --proxy-timeout / MCPX_PROXY_TIMEOUT) that bounds how long the daemon waits for a chat-completions upstream, returning 502 when the deadline passes before response headers | ||
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package e2e_test | ||
|
|
||
| import ( | ||
| "io" | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "strings" | ||
| "testing" | ||
| "time" | ||
| ) | ||
|
|
||
| func TestProxyUpstreamTimeoutIsReachableFromTheEnvironment(t *testing.T) { | ||
| upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| select { | ||
| case <-r.Context().Done(): | ||
| return | ||
| case <-time.After(200 * time.Millisecond): | ||
| } | ||
| w.Header().Set("Content-Type", "application/json") | ||
| _, _ = io.WriteString(w, `{"id":"chatcmpl-proxy-timeout-probe"}`) | ||
| })) | ||
| defer upstream.Close() | ||
|
|
||
| proxyStatus := func(t *testing.T, e *env) int { | ||
| t.Helper() | ||
| e.run("ls") // starts the isolated daemon with its final environment/config | ||
| client := e.socketClient(t) | ||
| req, err := http.NewRequest(http.MethodPost, "http://mcpx/v1/chat/completions", | ||
| strings.NewReader(`{"messages":[{"role":"user","content":"hello"}]}`)) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| req.Header.Set("X-Upstream-Url", upstream.URL) | ||
| resp, err := client.Do(req) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| defer resp.Body.Close() | ||
| _, _ = io.Copy(io.Discard, resp.Body) | ||
| return resp.StatusCode | ||
| } | ||
|
|
||
| defaultEnv := newEnv(t, oneServer) | ||
| if got := proxyStatus(t, defaultEnv); got != http.StatusOK { | ||
| t.Fatalf("default timeout status = %d, want 200", got) | ||
| } | ||
|
|
||
| shortEnv := newEnv(t, oneServer).withEnv("MCPX_PROXY_TIMEOUT=25ms") | ||
| if got := proxyStatus(t, shortEnv); got != http.StatusBadGateway { | ||
| t.Fatalf("25ms proxy timeout status = %d, want 502", got) | ||
| } | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package settings | ||
|
|
||
| import "github.com/developing-today/code/pkgs/mcpx/internal/defaults" | ||
|
|
||
| // proxySettings govern requests the daemon forwards to an LLM provider. | ||
| func proxySettings() []Setting { | ||
| return []Setting{ | ||
| { | ||
| Path: "proxy.timeout", Scope: ScopeDaemon, Kind: KindDuration, | ||
| Default: defaults.Builtin().Proxy.Timeout, | ||
| Commands: []string{"daemon"}, | ||
| Name: "Proxy upstream timeout", | ||
| Short: "how long the daemon waits for a chat-completions upstream", | ||
| Long: "The deadline covers the upstream response, including reading its body. " + | ||
| "A timeout before response headers arrive is returned to the caller as " + | ||
| "a 502. A stream that exceeds the deadline after headers have been sent " + | ||
| "is cut off, because an HTTP response status cannot be changed mid-stream.", | ||
| }, | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
The new Markdown fragment has no entry in
docs/compendium.manifest.json, so it introduces a failure inTestEveryDocumentHasAChapter. That test walks all module Markdown files, includingdocs/changes/, and reports any file absent from the manifest (internal/settings/compendium_test.go:123–166). Add an entry for this fragment, using thenot-compendiumrole if appropriate for release-history fragments. This also follows the explicit documentation-registration requirement ininternal/AGENTS.md.AGENTS.md reference: pkgs/mcpx/internal/AGENTS.md:L17-L18
Useful? React with 👍 / 👎.
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.
Fixed in 90bb132 (pushed to queue/3088-2114-proxy-timeout): added the
docs/changes/proxy-timeout.mdentry topkgs/mcpx/docs/compendium.manifest.jsonwith rolenot-compendium, matching the other docs/changes fragments. Verified on the laptop:TestEveryDocumentHasAChapterno longer lists proxy-timeout.md; its 4 remaining unregistered files (TESTING.md, docs/changes/docs-history-tool.md, docs/changes/protocol-capability-claims.md, docs/changes/research-and-findings-chapter.md) are identical on clean main — pre-existing, not introduced by this PR. Disposition by queue task 8803 (repo-worker-code, lane code-f).