AS AgentScopeAPI 手册 / API Reference

AtPathExpansionMiddleware

public class AtPathExpansionMiddleware implements HarnessRuntimeMiddleware
源码Source io/agentscope/harness/agent/middleware/AtPathExpansionMiddleware.java:67–196

At 路径 Expansion 中间件,在智能体执行流程中提供横切扩展。位于 io.agentscope.harness.agent.middleware 包,实现 HarnessRuntimeMiddleware。核心成员包括 onAgent、AtPathExpansionMiddleware。

Expands @path references in user messages by reading the referenced files through the active AbstractFilesystem and appending an <attached_file> block at the end of the message. Mirrors the Claude Code CLI's @file input syntax.

Dispatch by filesystem type (kept as in-line instanceof since there is exactly one call site):

  • Local (OverlayFilesystem wrapping LocalFilesystemWithShell) — attempts fs.read; success triggers attachment, failure (typically because the path falls outside the PathPolicy allow-list) leaves the @path text untouched.

  • Sandbox (AbstractSandboxFilesystem, not wrapped in overlay) — treats the reference as a path inside the sandbox; host-path upload is out of scope for this stage.

  • Remote (CompositeFilesystem) — disabled. The agent is not co-located with the user so @path has no meaningful resolution; references are left as-is.

Recognises three reference shapes: absolute (@/abs/path), relative (@./rel or @rel/foo), and home-anchored (@~/file). A bare @word with no path-like character (slash, dot, tilde) is ignored to avoid swallowing handles such as @alice.

构造器摘要Constructor Summary

构造器Constructor说明Description
public AtPathExpansionMiddleware(WorkspaceManager workspaceManager)
初始化 `AtPathExpansionMiddleware` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public Flux<AgentEvent> onAgent(Agent agent, RuntimeContext ctx, AgentInput input, Function<AgentInput, Flux<AgentEvent>> next)
处理智能体事件。
Performs the on agent operation.

构造器详情Constructor Detail

AtPathExpansionMiddleware

public AtPathExpansionMiddleware(WorkspaceManager workspaceManager)

初始化 AtPathExpansionMiddleware 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
workspaceManagerWorkspaceManager工作区管理器(类型 `WorkspaceManager`)。The workspace manager.
源码Source io/agentscope/harness/agent/middleware/AtPathExpansionMiddleware.java:90–92

方法详情Method Detail

onAgent

public Flux<AgentEvent> onAgent(Agent agent, RuntimeContext ctx, AgentInput input, Function<AgentInput, Flux<AgentEvent>> next)

处理智能体事件。

Performs the on agent operation.

参数Parameters
名称Name类型Type说明Description
agentAgent智能体(类型 `Agent`)。The agent.
ctxRuntimeContext运行时上下文(类型 `RuntimeContext`)。The ctx.
inputAgentInput输入消息(类型 `AgentInput`)。The input.
nextFunction<AgentInput, Flux<AgentEvent>>下一个(类型 `Function >`)。The next.
返回Returns Flux<AgentEvent>
返回Flux。Returns flux.
源码Source io/agentscope/harness/agent/middleware/AtPathExpansionMiddleware.java:94–121

继承成员Inherited Members

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.