fix: Resolve channel default_agent by name at message-time instead of caching UUID at startup#542
Open
psumo wants to merge 1 commit intoRightNow-AI:mainfrom
Open
fix: Resolve channel default_agent by name at message-time instead of caching UUID at startup#542psumo wants to merge 1 commit intoRightNow-AI:mainfrom
psumo wants to merge 1 commit intoRightNow-AI:mainfrom
Conversation
… caching UUID at startup When a channel's default_agent is resolved at startup, the UUID gets cached in the AgentRouter. Kill + respawn assigns a new UUID but the router keeps the old one, so all messages fail with "Agent not found" until you restart the process. Added a lazy re-resolution fallback in the bridge dispatch path — on "Agent not found", look up the configured agent name, call find_agent_by_name() for the current UUID, update the cache, retry. No overhead on the normal path.
adaab46 to
15725c8
Compare
This was referenced Mar 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a channel's
default_agentis resolved at startup, the UUID gets cached in theAgentRouter. Kill + respawn assigns a new UUID, but the router still holds the old one. Every message after that fails withAgent not found: <old-uuid>until you restart the whole process.I kept hitting this while iterating on agent manifests:
agent kill foo+agent spawn fooFix
Lazy re-resolution fallback in the bridge dispatch path. When
send_message()gets an "Agent not found" error:find_agent_by_name()to get the current UUIDThe cached UUID is still checked first so there's no overhead in the normal case. Re-resolution only kicks in when the send actually fails.
Changes
crates/openfang-channels/src/router.rs(+24 lines)channel_default_names: DashMap<String, String>field — stores the configured agent name next to the cached UUIDset_channel_default_with_name()— stores both name and IDchannel_default_name()— getter for the stored nameupdate_channel_default()— swap out just the cached UUID after re-resolutioncrates/openfang-channels/src/bridge.rs(+117 lines)try_reresolution()— checks for "Agent not found", looks up name from router, callsfind_agent_by_name(), updates cache, returns new IDdispatch_message()error path — on "Agent not found", tries re-resolution + one retrydispatch_with_blocks()— same logic for multimodal messagesblocks→blocks.clone()so blocks can be reused on retrycrates/openfang-api/src/channel_bridge.rs(1 line)set_channel_default()→set_channel_default_with_name()at startup so the name is preservedBackwards compat
set_channel_default()is untouched — only the startup path uses the new_with_namevariantfind_agent_by_name()AgentRouterare privateTesting
default_agent = "foo"agent kill foo→agent spawn fooAgent error: Agent not found: ...Edge cases: