Skip to content
PidebugBackend4 files · +210 −88

Fix Gradio /call/{api_name} state handling for stateful queued requests

Session from gradio-pi-sessions on Hugging Face by abidlabs · MIT · condensed by Coders Talk

1h 10msession
1interventions
GOAL

Reproduce and fix GitHub issue #8452 where the gradio_api /call/{api_name} route did not correctly persist session state across curl/bash-style API requests, then open a PR.

  1. Prompt · +13m
    Check if github.com/gradio-app/gradio/issues/8452 is still an issue, and if so, fix it.
  2. Agent did · +13m
    Set up a worktree for the issue, read the GitHub issue, and traced through routes.py and queueing.py to find how session_hash and Event state are handled for /call/{api_name} requests.
  3. Agent did · +15m
    Edited routes.py to route SSE reads through the original session_hash and updated test_routes.py with a new regression test for stateful bash-API calls.
  4. Fail · +19m
    Manual demo script crashed with a Chatbot type error and a follow-up pytest/demo run hit a startup port error.
  5. Intervention · +27m
    Developer said 'try again' after the demo run failed to start correctly.
    Why: The demo script was broken so I just told it to retry rather than debug it myself.
  6. Agent did · +28m
    Fixed the demo script format, verified state persisted across chat turns via SSE, ran the regression test and ruff checks, committed, pushed, and opened PR #13515.
  7. Prompt · +39m
    Make the curl requests yourself against the local 7864 endpoint and compare with the public HF Space demo.
  8. Agent did · +39m
    Ran curl tests against the local patched demo and the HF Space, then against the same demo on unpatched main, confirming the fix and updating the PR description with reproduction steps and results.
  9. Prompt · +1h 10m
    Review GitHub Copilot's review comment on the PR; if you agree, adopt its suggestion and push, otherwise respond.
  10. Outcome · +1h 10m
    Adopted Copilot's suggestion to pad skip_api inputs, extended the test, pushed a follow-up commit, and replied to the review comment; PR #13515 open with passing regression test and ruff checks.
VERDICT

Next time I'd start by asking it to reproduce the bug locally with a runnable demo script before touching routes.py, since the first demo attempt crashed and wasted a cycle. Telling it to just 'try again' on the broken demo worked fine here, but the real value-add was having it actually run curl comparisons against the HF Space and against unpatched main rather than just asserting the fix worked. Acting on Copilot's review comment directly (pad skip_api inputs, not just stateful ones) caught an edge case I hadn't tested myself.

I tried this · 0

Discussion · 0

How Builds work