Skip to content

fix(harness): import fi.simulate on the callback adapter's main thread - #147

Closed
KarthikAvinashFI wants to merge 1 commit into
devfrom
fix/callback-adapter-main-thread-import
Closed

KarthikAvinashFI wants to merge 1 commit into
devfrom
fix/callback-adapter-main-thread-import

Conversation

@KarthikAvinashFI

Copy link
Copy Markdown
Member

Why

Every hosted chat run of a callback-style agent fails before the first turn with target_agent_failed: Plugins must be registered on the main thread.

The callback adapter imports fi.simulate inside _invoke, which runs on a ThreadingHTTPServer worker thread. With livekit installed, as in the hosted runtime image, that import registers livekit plugins, and livekit refuses registration off the main thread. Voice agents do not use this adapter and are unaffected.

What changed

File Change
src/fi/alk/harness/callback_http_adapter.py from fi.simulate import AgentInput moves to module level, so it runs on the main thread at process start.
tests/harness/test_callback_http_adapter.py Runs the adapter as a bundle does (its source copied out of the package) and sends one /invoke. Fails before the fix when livekit is installed; passes after.

Testing

  • New test: fails on dev and passes on this branch, in an environment with the livekit extra.
  • tests/harness -k "bundle_author or callback or chat": 114 passed.
  • ruff check and ruff format --check clean.

@KarthikAvinashFI KarthikAvinashFI self-assigned this Oct 9, 2026
@KarthikAvinashFI
KarthikAvinashFI marked this pull request as ready for review October 9, 2026 04:42
@KarthikAvinashFI

Copy link
Copy Markdown
Member Author

Folded into #128.

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