Skip to content

fix: honor control-plane-assigned PORT instead of hardcoding 8003#89

Merged
AbirAbbas merged 1 commit into
mainfrom
fix/honor-port
Jul 7, 2026
Merged

fix: honor control-plane-assigned PORT instead of hardcoding 8003#89
AbirAbbas merged 1 commit into
mainfrom
fix/honor-port

Conversation

@AbirAbbas

Copy link
Copy Markdown
Collaborator

Summary

main() — the python -m swe_af / swe-af entry point — called app.run(port=8003, host="0.0.0.0"). 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. The hardcoded 8003 made the process bind the wrong port, so the readiness poll never succeeded:

✅ Assigned port: 8001
📡 Starting agent node process...
❌ Failed to run agent: agent node failed to start: agent node did not become ready within 10s

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-planner for everyone installing SWE-AF as an agent node.

Fix

Drop the explicit port:

app.run(host="0.0.0.0")

The SDK's Agent.run() reads PORT from 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-planner binds the assigned port and passes readiness.

Test

tests/test_main_entrypoint.py — contract test asserting main() never passes an explicit port to app.run() (mocks app.run, checks no positional/port= arg). compileall clean.

🤖 Generated with Claude Code

`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>
@AbirAbbas AbirAbbas merged commit 7839662 into main Jul 7, 2026
2 checks passed
@AbirAbbas AbirAbbas deleted the fix/honor-port branch July 7, 2026 23:28
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.

1 participant