Repository navigation
fix(harness): expose session workspace in prompt - #3020
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
This PR currently conflicts with the git fetch origin
git checkout fix/2941-session-workspace-context
git rebase origin/main
# resolve conflicts, then:
git push --force-with-leaseThis is a one-time reminder. Feel free to @mention me for a re-review after the conflicts are resolved. Automated notification by github-manager-bot |
|
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-review after the merge conflict was resolved (thanks for the quick rebase, and for the @mention). Conflicts are gone (mergeable: MERGEABLE), CLA is signed, and all checks pass on the current head — including build (windows-latest), which matters for a path-normalisation change.
The fix is the right shape: rather than patching the prompt string in isolation, it derives the advertised root from the same NamespaceFactory the filesystem already applies at operation time, and threads the operation's RuntimeContext through norm(...) so absolute and relative paths converge on one file. Reusing resolveRuntimeDataPath keeps a single source of truth, and the end-to-end sessionIsolation_absoluteAndRelativeWorkspacePathsResolveToSameFile test is the right way to pin that contract — asserting the negative (session-1/session-1/... must not exist) is especially good.
Verdict: no blocking issues; left as COMMENT so the three questions below can be answered or explicitly deferred. Two are about how safely this new dual-mode normaliser resists future misuse, one is a scope question about an adjacent prompt section that appears to have the same bug class as #2941.
Findings
- [Warning]
WorkspacePathNormalizer.java:100— the 1-argnormalize(String)overload now silently resolves the namespace from an empty context, which reproduces the double-nesting bug for any caller that does not pass aRuntimeContext. - [Warning]
WorkspacePathNormalizer.java:123— namespace segments are treated as trusted path components; worth pinning the contract with id sanitisation (#2952) via a hostile-id test. - [Info]
WorkspaceContextMiddleware.java:219—buildKnowledgeBlockstill receives the base workspace, soKnowledge files:stays relative to the un-namespaced root: same bug class as #2941, or intentional? - [Info]
WorkspaceContextMiddleware.java:243— two adjacentPathparams distinguished only by name; a small holder type would prevent future mix-ups. - [Info]
WorkspacePathNormalizer.java:118— multi-segment namespaces and the empty-namespace overlay case are untested.
Suggestions
- For the overload: prefer making the safe path the only path — either
@Deprecatedthe 1-arg method with a note, or have it throw (or at leastlog.warn) whennamespaceFactory != null. A compile-time/deprecation warning is much cheaper than a misplaced artifact at runtime. - For the knowledge block: if base-scoped is deliberate, a one-line comment saying so is enough; otherwise it likely wants
effectiveWorkspacetoo. - Consider a test asserting the rendered prompt is unchanged when isolation is disabled, so the refactor of
buildWorkspaceParagraphis provably behaviour-preserving for the common single-tenant configuration.
Automated review by github-manager-bot
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-review after 443c3502 (the only author commit since my last review — the other new commits are upstream resync merges). Thanks for the follow-up: conflict resolution, @Deprecated on the unscoped overload, and the mention ping.
What I verified this round:
- Scope of the new commit:
git diff 1f5b9b7f..443c3502touches onlyWorkspacePathNormalizerjavadoc +@Deprecated. No behaviour change, so the previously reviewed logic (single source of truth viaresolveRuntimeDataPath,RuntimeContextthreaded throughnorm(...)) still stands. - Migration is complete in main:
FilesystemTool.normandArtifactDeliveryTool.normare the only production call sites and both pass theRuntimeContext, so the deprecated overload has no in-repo users. That is what makes the finding below a hardening note rather than a defect. - Gate correctness: the namespaced strip is only wired in for the
OverlayFilesystem+LocalFilesystemWithShellbranch (HarnessAgent.java:2692), and the new prompt test asserts both the positive (session-1advertised) and the negative (Additional rootsdoes not absorb the workspace) — good. - CI / CLA / conflicts:
check,check windows build,check codeql,check license/clagreen on head443c3502;mergeable: MERGEABLE,mergeStateStatus: BLOCKED(blocked on review/merge settings, not on conflicts).
Verdict: no new blocking issues; nothing here changes my previous assessment. Not approving because the five threads from my previous review are still open and unresolved — I have not restated them; the three notes below are the new ones only, all non-blocking. If you consider the open questions addressed or deferred, resolve the threads (or reply "deferred: …") and @mention me for an approval pass.
Automated review by github-manager-bot
oss-maintainer
left a comment
There was a problem hiding this comment.
Summary
Re-review on head 11d3a165 in response to the @mention. The only new commits since my last review (443c3502) are upstream main resync merges — no further changes to the PR's own code, and the merge resolved the previous conflict cleanly.
Verified this round:
- All 8 review threads from previous rounds are resolved.
- The namespaced-strip path in
WorkspacePathNormalizer.normalize(path, rc)is still correct after the resync: namespaced prefix checked before the unscoped prefix,RuntimeContextthreaded throughFilesystemTool/ArtifactDeliveryTool, and the deprecated single-arg overload delegates with an empty context only. WorkspaceContextMiddlewareadvertises the effective (session-scoped) workspace consistently in both the session-context section and the workspace paragraph;knowledgeBlockintentionally keeps the unscoped root.- Prompt-bound test (
localOverlay_sessionIsolationAdvertisesEffectiveWorkspace) and round-trip test (sessionIsolation_absoluteAndRelativeWorkspacePathsResolveToSameFile) cover both the positive and negative assertions. - CI: 6/6 checks passing on
11d3a165; CLA signed;mergeable: MERGEABLE.
LGTM — approving.
Suggestions
- [non-blocking] If a path carries a different session's namespace segment (e.g.
/workspace/session-2/x.txtunder asession-1context), the unscoped fallback yieldssession-2/x.txt, which the filesystem then resolves under the active namespace. Current callers can't hit this via the prompt, but a defensive note in the javadoc would make the contract explicit.
Automated review by github-manager-bot
|
@jujn 打扰了,可以看看这个pr嘛,目前处于approve状态 |
|
Assign to @xiaoyuuuuuupeng (Review) |
Conflict resolutions: - ReActAgent.maybePatchPendingToolCalls: take upstream's shared MessageUtils.lastAssistantMessage(state.contextMutable()); fork's patchPendingToolCalls extraction was behaviour-equivalent and its findLastAssistantMsg() helper is deleted upstream. - AgentRunSandbox.shutdown: keep fork side. Upstream agentscope-ai#2302 (keep MCP channel open for non-owned sandboxes) is already covered — the fork replaced the MCP channel with the HTTP data plane and shutdown() is a deliberate no-op, with the isSandboxOwned() guard in destroyInstance(). - WorkspaceContextMiddleware.buildWorkspaceParagraph: combine both — upstream agentscope-ai#3020 effectiveWorkspace plus fork's RuntimeContext for the sandbox working directory. - Semantic fix: fork-only ToolRetryLater call site updated to the two-arg notifyPostActingHook(entry, false) introduced by agentscope-ai#2891. - AgentRunSandboxShutdownTest (added by agentscope-ai#2302) rewritten against the HTTP data plane / destroyInstance semantics. - Revision follows upstream at 2.0.4-SNAPSHOT.
Summary
Problem
With session isolation enabled, relative file-tool paths resolve under the session namespace (for example,
/workspace/session-1), while the prompt currently advertises the base workspace (/workspace). Models can therefore run skill scripts against the wrong path, write artifacts outside the session namespace, and then fail to find those artifacts through file tools.This change only corrects the path shown to the model. It reuses
WorkspaceManager.resolveRuntimeDataPathso the advertised path follows the same namespace factory already used by runtime data.Testing
mvn -pl agentscope-harness spotless:checkmvn -pl agentscope-harness -Dtest="WorkspaceContextMiddlewarePathBoundsTest,WorkspaceContextMiddlewareMemoryPromptTest,WorkspaceContextMiddlewareSandboxPromptTest,LocalFilesystemModeTest,LocalFilesystemWithShellTest" test(38 tests passed)Fixes #2941