Class AgentScopeAdapter
- All Implemented Interfaces:
FrameworkAdapter
This is the BYO path: the user writes and runs their own agent, and aistio observes it from
the side. It is unrelated to managed-agents mode, where the data plane service implements the
/agentscope/* contract directly because it owns the runtime.
Observation rides on AistioObserverMiddleware, which passes every input and event
through untouched. Context and history are read from AgentState, which is the same buffer
the agent will hand to its next model call, so what the console shows is what the model sees.
Middlewares are fixed when a ReActAgent is built, so the event stream requires
registering middleware() at build time:
AgentScopeAdapter adapter = new AgentScopeAdapter();
ReActAgent agent = ReActAgent.builder()
.middleware(adapter.middleware())
.build();
SessionBridge bridge = Aistio.instrument(agent, config, adapter);
An already-built agent can still be instrumented — snapshots, context, history and commands all read live state — but it produces no Level-2 events.
-
Field Summary
FieldsFields inherited from interface io.agentscope.extensions.aistio.FrameworkAdapter
CAP_AGENT_TASK, CAP_CONTEXT_QUERY, CAP_CONVERSATION_INBOUND, CAP_EXPORT_TRANSCRIPT, CAP_MESSAGE_QUERY, CAP_PLAN_MODE, CAP_SESSION_ABORT, CAP_SESSION_COMMAND, CAP_SUBAGENT_INVENTORY, CAP_SUBAGENT_TASK_COMMAND, CAP_SUBAGENT_TASK_QUERY, CAP_TASK_QUERY, CAP_WORKSPACE_INVENTORY, COMMAND_ABORT, COMMAND_COMPRESS, COMMAND_TERMINATE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidattach(Object target, Consumer<SessionEvent> emit) Attaches to the framework object.Effective Definition snapshot forGET /agentscope/info→agentConfig.reactor.core.publisher.Mono<Void>cancelSubagentTask(String sessionId, String taskId) Cancel one background subagent task.booleanWhether this adapter can instrumenttarget.Capabilities contributed by this adapter.voiddetach()Removes the interception and restores the framework object.reactor.core.publisher.Mono<ContextSnapshot>extractContext(String sessionId) Level 4: the context that the session's next model call will actually see.Framework identifier reported on every snapshot, e.g.Framework version, or an empty string when it cannot be determined.reactor.core.publisher.Mono<Void>handleAgentTask(AgentTaskAssignment assignment) Materializes a downstream AgentTask delivery as an isolated execution.reactor.core.publisher.Mono<Void>handleCommand(String sessionId, String command, byte[] params) ExecutesFrameworkAdapter.COMMAND_COMPRESS,FrameworkAdapter.COMMAND_TERMINATE, orFrameworkAdapter.COMMAND_ABORTagainst the session.reactor.core.publisher.Mono<Void>injectUserMessage(String sessionId, String content) Inject a console/control-plane user message into the live session.reactor.core.publisher.Mono<MessagePage>listMessages(String sessionId, int offset, int limit) Level 3: full history including messages already compacted away.reactor.core.publisher.Mono<List<Inventory.SubagentInfo>>listSubagentTasks(String sessionId) Background subagent tasks forGET .../subagent-tasks(not todolist).Session task list forGET .../tasks.reactor.core.publisher.Mono<List<Inventory.WorkspaceInfo>>The middleware to register on the agent builder to enable the Level-2 event stream.voidonBridgeAttached(SessionBridge bridge) Called once the adapter is mounted, giving it a handle for metadata the event stream cannot carry — system prompt, tool list, context window — viaSessionBridge.describeSession(java.lang.String, java.lang.String, java.util.List<io.agentscope.extensions.aistio.model.ContextSnapshot.ToolInfo>, int).reactor.core.publisher.Mono<String>runConversationTurn(String sessionId, String content) Run a control-plane conversation turn and return its terminal assistant reply.voidsetAgentTaskStarter(AgentTaskStarter agentTaskStarter) Installs the host hook that materializes ASDP AgentTask deliveries.voidsetHistorySource(SessionHistorySource historySource) Optional full-history reader (e.g. harness.log.jsonl).reactor.core.publisher.Mono<Void>setPlanMode(String sessionId, byte[] params) Enter or exit plan mode for the session.voidsetRuntimeSource(AgentRuntimeSource runtimeSource) Optional harness-/app hooks for inventory, plan files, subagent tasks and Definition enrich.
-
Field Details
-
FRAMEWORK
- See Also:
-
-
Constructor Details
-
AgentScopeAdapter
public AgentScopeAdapter() -
AgentScopeAdapter
- Parameters:
compactor- handlescompress;nullleaves that command unsupported
-
-
Method Details
-
middleware
The middleware to register on the agent builder to enable the Level-2 event stream. -
setHistorySource
Optional full-history reader (e.g. harness.log.jsonl). Safe to set after the adapter bean is created, once theHarnessAgentexists. -
setRuntimeSource
Optional harness-/app hooks for inventory, plan files, subagent tasks and Definition enrich. -
setAgentTaskStarter
Installs the host hook that materializes ASDP AgentTask deliveries. -
frameworkName
Description copied from interface:FrameworkAdapterFramework identifier reported on every snapshot, e.g.agentscope-java.- Specified by:
frameworkNamein interfaceFrameworkAdapter
-
frameworkVersion
Description copied from interface:FrameworkAdapterFramework version, or an empty string when it cannot be determined.- Specified by:
frameworkVersionin interfaceFrameworkAdapter
-
canHandle
Description copied from interface:FrameworkAdapterWhether this adapter can instrumenttarget. Must be side-effect free.- Specified by:
canHandlein interfaceFrameworkAdapter
-
capabilities
Description copied from interface:FrameworkAdapterCapabilities contributed by this adapter. Push-side capabilities (session-reporting,event-reporting,context-reporting) are added by the bridge.- Specified by:
capabilitiesin interfaceFrameworkAdapter
-
attach
Description copied from interface:FrameworkAdapterAttaches to the framework object. Session activity is published throughemit, which must never be allowed to break the framework's main path.- Specified by:
attachin interfaceFrameworkAdapter
-
detach
public void detach()Description copied from interface:FrameworkAdapterRemoves the interception and restores the framework object.- Specified by:
detachin interfaceFrameworkAdapter
-
onBridgeAttached
Description copied from interface:FrameworkAdapterCalled once the adapter is mounted, giving it a handle for metadata the event stream cannot carry — system prompt, tool list, context window — viaSessionBridge.describeSession(java.lang.String, java.lang.String, java.util.List<io.agentscope.extensions.aistio.model.ContextSnapshot.ToolInfo>, int).- Specified by:
onBridgeAttachedin interfaceFrameworkAdapter
-
extractContext
Description copied from interface:FrameworkAdapterLevel 4: the context that the session's next model call will actually see.- Specified by:
extractContextin interfaceFrameworkAdapter
-
listMessages
public reactor.core.publisher.Mono<MessagePage> listMessages(String sessionId, int offset, int limit) Description copied from interface:FrameworkAdapterLevel 3: full history including messages already compacted away.- Specified by:
listMessagesin interfaceFrameworkAdapter
-
handleCommand
public reactor.core.publisher.Mono<Void> handleCommand(String sessionId, String command, byte[] params) Description copied from interface:FrameworkAdapterExecutesFrameworkAdapter.COMMAND_COMPRESS,FrameworkAdapter.COMMAND_TERMINATE, orFrameworkAdapter.COMMAND_ABORTagainst the session.- Specified by:
handleCommandin interfaceFrameworkAdapter
-
handleAgentTask
Description copied from interface:FrameworkAdapterMaterializes a downstream AgentTask delivery as an isolated execution.- Specified by:
handleAgentTaskin interfaceFrameworkAdapter
-
injectUserMessage
Description copied from interface:FrameworkAdapterInject a console/control-plane user message into the live session. Must use the framework's official continue-turn API.- Specified by:
injectUserMessagein interfaceFrameworkAdapter
-
runConversationTurn
Description copied from interface:FrameworkAdapterRun a control-plane conversation turn and return its terminal assistant reply. Unlike message injection, completion must carry the answer, not just acknowledge input.- Specified by:
runConversationTurnin interfaceFrameworkAdapter
-
listTasks
Description copied from interface:FrameworkAdapterSession task list forGET .../tasks. Each map follows the frozen Task shape:id,subject,state,owner,blockedBy,updatedAt,frameworkMeta.- Specified by:
listTasksin interfaceFrameworkAdapter
-
listSubagents
- Specified by:
listSubagentsin interfaceFrameworkAdapter
-
listWorkspaces
- Specified by:
listWorkspacesin interfaceFrameworkAdapter
-
listSubagentTasks
Description copied from interface:FrameworkAdapterBackground subagent tasks forGET .../subagent-tasks(not todolist). Each map is framework-shaped; typical keys:id,status,subject/label.- Specified by:
listSubagentTasksin interfaceFrameworkAdapter
-
cancelSubagentTask
Description copied from interface:FrameworkAdapterCancel one background subagent task. Capability:subagent-task-command.- Specified by:
cancelSubagentTaskin interfaceFrameworkAdapter
-
setPlanMode
Description copied from interface:FrameworkAdapterEnter or exit plan mode for the session. Capability:plan-mode.paramsis a JSON object with"active": true|false.- Specified by:
setPlanModein interfaceFrameworkAdapter
-
buildAgentConfig
Description copied from interface:FrameworkAdapterEffective Definition snapshot forGET /agentscope/info→agentConfig.- Specified by:
buildAgentConfigin interfaceFrameworkAdapter
-