{{ message }}
Repository navigation
perf(hooks): resolve tool-hook agents from session metadata - #3
Merged
Merged
Conversation
Atlas (tool.execute.before and .after) and prometheus-md-only read the whole session history on every tool call just to learn the agent's name. On OpenCode 2 each read decodes every stored attachment and validates it against Prompt.Base64; a JS profile of a turn in a session with four 1.3 MB images put two thirds of the regex time in these lookups. They now ask for the session's current agent first and fall back to the history lookup only when the client lacks the capability or the metadata is missing. Fork-Patch: v2-support
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
After #2 the sidebar no longer hydrates session history, but bursts of
Prompt.Base64validation remained at every tool step of a session with image attachments (CPU up to ~220%, API stalls up to 8 s on the VPS). A JSC ScriptProfiler capture of a turn start (5,160 regex samples) attributed:isCallerOrchestrator→findNearestMessageWithFieldsFromSDK(Atlas tool.execute.before/after)getAgentFromSession→findFirstMessageWithAgentFromSDK(prometheus-md-only tool.execute.before)Change
readCurrentSessionAgentasks the V2 facade'ssession.currentAgent(from #2). Both lookups use it first and keep the existing history path when the capability is absent or the metadata is missing. A compaction agent from metadata resolves to no agent, as in the history lookup.Verification