Repository navigation
Conversation
A managed session fails before its first turn when the control plane reports a namespaced owner id. sessionLogAgentId() joins "dpa-" + ownerId + "-" + agentId + "-" + sessionId and hands the result to HarnessAgent.Builder#agentId, which validates it through AgentBase.normalizeAgentId. With an owner id like "namespace:default" the assembled id becomes "dpa-namespace:default:default-...-sess_...", the validation rejects it with "Invalid agentId ...: must match [A-Za-z0-9._-]+", and SessionTurnRunner logs "Managed session turn failed" for every turn. Widening the pattern is not the fix: normalizeAgentId documents the id as a single path/namespace segment, harness pins it as the stable namespace key for composite-filesystem paths, and ':' is invalid in Windows paths anyway. Map characters outside the accepted alphabet to '-' per part instead, so the owner, agent and session parts stay readable and distinct, and an id that was already valid comes out unchanged. Fixes agentscope-ai#3705
This branch has not been deployed
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.
Description
Fixes #3705.
A managed session never runs when the control plane reports a namespaced owner id:
HarnessAgentBuildService#sessionLogAgentIdjoins three parts:and the result is passed to
HarnessAgent.Builder#agentId(...), which validates it throughAgentBase.normalizeAgentId. The colon comes from the owner id (namespace:default), not from the agent id, and the validation rejects the whole assembled value.Change
Took the first option from the issue: clean up on assembly, not widen the pattern.
Widening
[A-Za-z0-9._-]is not safe here.normalizeAgentIddocuments the id as a single path/namespace segment,HarnessAgent.Builder#agentIdpins it as the stable namespace key for composite-filesystem paths, and:is invalid in Windows paths regardless. So the assembled parts now go through a segment mapper that replaces anything outside the accepted alphabet with-:Mapping instead of stripping keeps the owner, agent and session parts readable and distinct (dropping the namespace would let two namespaces with the same name collide). An id that was already valid is returned unchanged, so nothing changes for owners without a namespace prefix.
Tests
Added to
HarnessAgentBuildServiceCacheKeyTest:sessionLogAgentIdIsValidForNamespacedOwnerIds— builds a session withownerId = "namespace:default", asserts the assembled id and runs it throughAgentBase.normalizeAgentId, which is the check that was failing.sessionLogAgentIdLeavesValidIdsUntouched— the plainowner-1case still yieldsdpa-owner-1-bbb-sess_1.Without the change the first test fails on the assembled id (
dpa-namespace:default-default-..., colon still there), which is exactly whatnormalizeAgentIdrejects in the reported log line.