fix: honor control-plane-assigned PORT instead of hardcoding 8003#89
Merged
Conversation
`main()` (the `python -m swe_af` / `swe-af` entry point) called `app.run(port=8003, ...)`. Under `af run`, the AgentField control plane assigns a free port per launch, exports it as the PORT env var, and polls readiness on that port — but the hardcoded 8003 made the process bind the wrong port, so the readiness check timed out with "agent node did not become ready within 10s" and the control plane killed it. Drop the explicit port. The SDK's `Agent.run()` reads PORT when no port is passed (and auto-selects a free port when run standalone), which is the intended control-plane integration path. Adds a contract test asserting `main()` never passes an explicit port to `app.run()`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
main()— thepython -m swe_af/swe-afentry point — calledapp.run(port=8003, host="0.0.0.0"). Underaf run, the AgentField control plane assigns a free port per launch, exports it as thePORTenv var, and polls readiness on that port. The hardcoded8003made the process bind the wrong port, so the readiness poll never succeeded:The agent had actually started fine — just on 8003 instead of the assigned 8001 — so the control plane killed it as unready. This blocks
af run swe-plannerfor everyone installing SWE-AF as an agent node.Fix
Drop the explicit port:
The SDK's
Agent.run()readsPORTfrom the env when no port is passed (the control-plane integration path), and auto-selects a free port when run standalone. Verified end-to-end: after the change,af run swe-plannerbinds the assigned port and passes readiness.Test
tests/test_main_entrypoint.py— contract test assertingmain()never passes an explicit port toapp.run()(mocksapp.run, checks no positional/port=arg).compileallclean.🤖 Generated with Claude Code