Skip to content

fix: honor PORT injected by af run (unbreak install-and-run)#49

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

fix: honor PORT injected by af run (unbreak install-and-run)#49
AbirAbbas merged 1 commit into
mainfrom
fix/honor-injected-port

Conversation

@AbirAbbas

Copy link
Copy Markdown
Contributor

Problem

af run pr-af fails its readiness check:

❌ Failed to run agent: agent node failed to start: agent node did not become ready within 10s

pr_af/app.py calls app.run(port=8004, host="0.0.0.0") with a hardcoded port. The SDK treats an explicitly-passed port as the highest-priority override, so it ignores the PORT environment variable the AgentField runner injects after it allocates a free port. The node binds 8004 while the CLI polls the port it assigned (e.g. 8001), so the health poll never sees the node and times out.

The other agent nodes (sec-af, cloudsecurity-af) already read PORT and run fine on af run; pr-af was the only one hardcoding it.

Fix

app.run(port=int(os.getenv("PORT", "8004")), host="0.0.0.0")

Honors the runner-injected PORT, keeps 8004 as the standalone default (python -m pr_af.app). os is already imported.

Verification

Installed the patched node and launched it directly with PORT=8011:

ℹ️ Starting agent node 'pr-af' on port 8011
INFO:     Uvicorn running on http://0.0.0.0:8011
$ curl localhost:8011/health → {"node_id":"pr-af", ...}

Pre-fix it bound 8004 regardless of PORT.

🤖 Generated with Claude Code

pr-af called `app.run(port=8004)` with a hardcoded port. The SDK treats an
explicit port as the highest-priority override, so it ignored the PORT env
var the AgentField runner injects when it allocates a free port. Result:
`af run pr-af` bound 8004 while the CLI polled its assigned port, and the
readiness check timed out ('agent node did not become ready within 10s').

Read PORT with an 8004 fallback (same pattern sec-af/cloudsecurity-af use),
so `af run` works out of the box while standalone `python -m pr_af.app`
still defaults to 8004.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@AbirAbbas AbirAbbas merged commit 0ec5881 into main Jul 8, 2026
2 checks passed

@AbirAbbas AbirAbbas left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 PR-AF Review — Looks Good

Safe to merge. No findings from automated review.

Automated multi-agent code review · PR-AF built with AgentField

0 findings · 🚫 0 blocking · 💬 0 advisory · 🔴 0 critical · 🟠 0 important · 🔵 0 suggestions · ⚪ 0 nitpicks

PR Overview

Problem

af run pr-af fails its readiness check:

❌ Failed to run agent: agent node failed to start: agent node did not become ready within 10s

pr_af/app.py calls app.run(port=8004, host="0.0.0.0") with a hardcoded port. The SDK treats an explicitly-passed port as the highest-priority override, so it ignores the PORT environment variable the AgentField runner injects after it allocates a free port. The node binds 8004 while the CLI polls the port it assigned (e.g. 8001), so the health poll never sees the node and times out.

The other agent nodes (sec-af, cloudsecurity-af) already read PORT and run fine on af run; pr-af was the only one hardcoding it.

Fix

app.run(port=int(os.getenv("PORT", "8004")), host="0.0.0.0")

Honors the runner-injected PORT, keeps 8004 as the standalone default (python -m pr_af.app). os is already imported.

Verification

Installed the patched node and launched it directly with PORT=8011:

ℹ️ Starting agent node 'pr-af' on port 8011
INFO:     Uvicorn running on http://0.0.0.0:8011
$ curl localhost:8011/health → {"node_id":"pr-af", ...}

Pre-fix it bound 8004 regardless of PORT.

🤖 Generated with Claude Code

No issues found. This PR looks clean across all review dimensions.

Review Process Details

Dimensions Analyzed (1):

  • callback_url default still hardcodes 8004 while bound port is now dynamic — 1 file(s)

Meta-Dimension Lenses (3):

  • Semantic — 2 dimension(s), 82% coverage confidence
  • Mechanical — 2 dimension(s), 82% coverage confidence
  • Systemic — 2 dimension(s), 82% coverage confidence
Pipeline Stats
Metric Value
Duration 386.8s
Agent invocations 5
Coverage iterations 0
Estimated cost N/A (provider does not report cost)
Budget exhausted Yes (timeout: 386s > 300s limit)
PR type bugfix
Complexity trivial

Review ID: rev_dfaf33221e78


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