Skip to content

feat: inbound tasks run through the DSH agent loop (tools, memory, auth) - #1

Merged
ryubyte merged 3 commits into
mainfrom
feat/inbound-dsh-agent-executor
Aug 19, 2026
Merged

ryubyte merged 3 commits into
mainfrom
feat/inbound-dsh-agent-executor

Conversation

@ryubyte

@ryubyte ryubyte commented Aug 19, 2026

Copy link
Copy Markdown
Owner

概要

Server 模式收到入站 A2A 任务时,默认交给本 DSH 自己的 agent
会话执行(不再只能拒绝),并补齐让它真正能干活的配套:工具、跨轮
记忆、鉴权。

改动

入站 executor(核心)

  • createDshAgentExecutor:检测到 agent-loop factory
    时,入站任务 → 本 DSH agent 会话执行;缺 factory 时退回
    notConfiguredExecutor(拒绝并给可读指引)。
  • 每 A2A contextId 一个会话:首个任务 create,同 contextId
    后续复用(历史累积),进程重启按需 resume;同 context
    串行、不同 context 并行;卸载/下线时统一 dispose。
  • 挂载 agent preset(create 的 setup 钩子调
    agentPresets.mount)——否则 spawn 的 agent 落在 empty global
    layer,没有 bash/fs 工具,只能把 <invoke> 当文本输出。
  • ctx.agentDefaultModel 注入 model——否则 persona system
    prompt 的 {{model}} 变量为空,回合直接报错。
  • 会话命名 A2A: <首条消息摘要>(入站消息带 plugin 来源,DSH
    自动标题只认 human 消息,故显式命名);入站会话用专用 cwd
    <profile>/.a2a-sessions,落在会话列表「未分组」。

修复

  • CancelTask 现在真正 abort 运行中 executor 的信号(之前
    runTask 用的是丢弃了 controller 的 signal,abort
    是死代码);并且不再让返回的 executor 把已 CANCELED 的任务覆盖成
    COMPLETED、避免 onTaskSettled 二次触发。

出站

  • 出站工具调用按本地 agent 会话复用同一 contextId,使远程
    agent 获得跨轮记忆;不同本地会话相互隔离,无 agent
    上下文时用稳定 fallback。

鉴权 / UI

  • 入站可选共享 Bearer Token:运行时 A2AServer.setAuthToken() +
    持久化到 a2a.json;AgentCard 声明 bearerAuth,未带/错误
    token 返回 401(单次调用与 SSE 流均生效)。
  • 连接面板:出站「添加 Agent」加 Bearer Token 输入;「A2A
    服务」加入站鉴权设置/清除控件;修正 executor
    语义提示(旧的"默认会执行 shell"假警告已移除)。

修复

  • CancelTask 现在真正 abort 运行中 executor 的信号(之前 runTask 用的是丢弃了
    controller 的 signal,abort 是死代码);并且不再让返回的 executor 把已 CANCELED
    的任务覆盖成 COMPLETED、避免 onTaskSettled 二次触发。

出站

  • 出站工具调用按本地 agent 会话复用同一 contextId,使远程 agent
    获得跨轮记忆;不同本地会话相互隔离,无 agent 上下文时用稳定 fallback。

鉴权 / UI

  • 入站可选共享 Bearer Token:运行时 A2AServer.setAuthToken() + 持久化到
    a2a.json;AgentCard 声明 bearerAuth,未带/错误 token 返回 401(单次调用与 SSE
    流均生效)。
  • 连接面板:出站「添加 Agent」加 Bearer Token 输入;「A2A
    服务」加入站鉴权设置/清除控件;修正 executor 语义提示(旧的"默认会执行
    shell"假警告已移除)。

所有可选宿主服务(agents / agentDefaultModel / sessionTitle /
agentPresets)经反射探测、结构化读取,不引入硬依赖;缺失则优雅退化。

测试

  • 37/37 单测通过(node:test + tsx),typecheck 与 client-bundle smoke 通过。
  • 真机验证:纯文本问答、工具执行(真实 bash 写文件落盘)、每 contextId
    复用/隔离、取消中止 agent 回合、Bearer 401/放行、model 注入。

Add `createDshAgentExecutor`: when an agent-loop factory is present, inbound
tasks run through this harness's own agent session instead of being refused.

- One session per A2A `contextId` (create-or-resume, reused across tasks so
  history accumulates; per-context serialized, distinct contexts parallel).
- Mount the deployment's agent preset in the create `setup` hook so the
  spawned agent actually gets tools/persona/skills (without it the agent
  publishes against the empty global layer and can't run bash/fs).
- Seed the model per task from `ctx.agentDefaultModel` so the persona prompt's
  `{{model}}` variable resolves (otherwise the turn errors before any output).
- Name each session `A2A: <first prompt summary>` via `ctx.sessionTitle`;
  inbound sessions use a dedicated `<profile>/.a2a-sessions` cwd.
- Dispose all live sessions on plugin unload.

Also:
- CancelTask now aborts the running executor's signal (was a no-op) and no
  longer lets the returning executor overwrite the CANCELED state.
- Outbound tools reuse one `contextId` per local agent session, giving remote
  agents cross-turn memory; distinct local sessions stay isolated.
- Optional host services (agents/agentDefaultModel/sessionTitle/agentPresets)
  are read structurally via a reflection probe — no hard dependency added.
- Executor precedence: per-contextId DSH agent session by default, refuse when
  no agent loop is present.
- Outbound cross-turn memory (one contextId per local agent session).
- Inbound bearer-token auth capability; note both outbound and inbound tokens
  are stored plaintext in a2a.json.
Recapture the settings panel: outbound tab with the bearer-token input (client),
A2A service tab with the executor note and inbound-auth control (server).
@ryubyte
ryubyte merged commit 7760d3f into main Aug 19, 2026
1 check passed
@ryubyte
ryubyte deleted the feat/inbound-dsh-agent-executor branch August 19, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant