Skip to content

fix: fall back to legacy API when agent create returns HTML#19

Closed
michaelschecht wants to merge 1 commit intoax-platform:mainfrom
michaelschecht:fix/agents-create-fallback
Closed

fix: fall back to legacy API when agent create returns HTML#19
michaelschecht wants to merge 1 commit intoax-platform:mainfrom
michaelschecht:fix/agents-create-fallback

Conversation

@michaelschecht
Copy link
Copy Markdown
Contributor

Summary

  • ax agents create fails because /agents/manage/create is caught by the frontend, returning HTML instead of JSON
  • Added fallback: when the management API raises HTTPStatusError, retry via the legacy /api/v1/agents endpoint

Test plan

  • Verified ax agents create "test-agent" --json succeeds after the fix
  • Confirmed the created agent appears in ax agents list
  • Verify management API path works once the backend route is fixed (fallback becomes a no-op)

🤖 Generated with Claude Code

The /agents/manage/create route is caught by the frontend, returning
HTML instead of JSON. Add a fallback to /api/v1/agents when the
management API fails with an HTTPStatusError.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@madtank
Copy link
Copy Markdown
Member

madtank commented Apr 7, 2026

Hi @michaelschecht — closing this with credit. Your fix landed on dev/staging via PR #23 (#23), which I cherry-picked from your fix/agents-create-fallback branch. The cherry-pick preserved you as the original author (Mike <michaelschecht@outlook.com>); the commit is 53827dc on dev/staging and is part of the dev/staging → main promotion PR.

Why the cherry-pick instead of merging this PR directly: your branch is based on un-formatted main, but dev/staging now has a ruff-format baseline from PR #22 that you didn't have. Re-targeting this PR's base from main to dev/staging would have produced a noisy diff fighting the format changes. Cherry-picking onto a fresh branch was the cleanest path that kept your contribution intact.

Two minor review notes I filed as future-work suggestions, not blockers (fully visible in PR #23's description):

  1. The catch is httpx.HTTPStatusError which is broader than "returned HTML" — it'd also fall back on 401, 500, etc. Could narrow to specifically detect HTML responses via Content-Type / body sniff.
  2. Silent fallback with no log message — adding a logger.warning("management API failed, falling back to legacy") would help debugging if the management API stays broken.

Both are nice-to-haves. The fix as-is ships real value. Thanks for the contribution!

Closing this PR — tracking further work on PR #23.

@madtank madtank closed this Apr 7, 2026
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.

2 participants