Class AguiStreamContext

java.lang.Object
io.agentscope.core.agui.adapter.strategy.AguiStreamContext

public class AguiStreamContext extends Object
  • Constructor Details

    • AguiStreamContext

      public AguiStreamContext(String threadId, String runId, AguiAdapterConfig config)
    • AguiStreamContext

      public AguiStreamContext(String threadId, String runId, AguiAdapterConfig config, RunAgentInput runInput)
    • AguiStreamContext

      public AguiStreamContext(String threadId, String runId, AguiAdapterConfig config, RunAgentInput runInput, Predicate<String> isExternalTool)
      Stream conversion context.

      The isExternalTool predicate tells whether a tool call resolves to an external tool (executed outside the framework, e.g. a frontend-provided or schema-only tool). When emitToolCallArgs is disabled, external tools still need TOOL_CALL_ARGS so the client can invoke them. Pass null to fall back to matching tool names from RunAgentInput.getTools() (used when no live toolkit is available, e.g. replay).

      Parameters:
      isExternalTool - predicate for external-tool resolution by tool name
  • Method Details

    • getThreadId

      public String getThreadId()
    • getRunId

      public String getRunId()
    • getConfig

      public AguiAdapterConfig getConfig()
    • getRunInput

      public RunAgentInput getRunInput()
    • beginEvent

      public void beginEvent()
    • drainEvents

      public List<AguiEvent> drainEvents()
    • emit

      public void emit(AguiEvent event)
    • startTextMessage

      public void startTextMessage(String messageId)
    • appendTextDelta

      public void appendTextDelta(String messageId, String delta)
    • closeActiveTextMessage

      public void closeActiveTextMessage()
    • closeTextMessage

      public void closeTextMessage(String messageId)
    • startReasoningMessage

      public void startReasoningMessage(String messageId)
    • appendReasoningDelta

      public void appendReasoningDelta(String messageId, String delta)
    • closeActiveReasoningMessage

      public void closeActiveReasoningMessage()
    • closeReasoningMessage

      public void closeReasoningMessage(String messageId)
    • startToolCall

      public void startToolCall(String toolCallId, String toolCallName)
    • appendToolCallArgs

      public void appendToolCallArgs(String toolCallId, String delta)
    • endToolCall

      public void endToolCall(String toolCallId)
    • adoptToolCall

      public void adoptToolCall(String toolCallId)
      Accept results for a tool call whose invocation was emitted in a previous run.

      Callers must obtain the id from a known pending tool call, such as a validated user confirmation. Adoption is idempotent and emits no events. It does not start a tool call in this run, enable argument events, or clear an existing result buffer. Null or blank ids are ignored, just as they are for tool-call events.

      Parameters:
      toolCallId - stable id of the previously emitted tool call
    • beginToolResult

      public void beginToolResult(String toolCallId)
    • appendToolResultText

      public void appendToolResultText(String toolCallId, String delta)
    • appendToolResultData

      public void appendToolResultData(String toolCallId, io.agentscope.core.message.ContentBlock data)
    • endToolResult

      public void endToolResult(String replyId, String toolCallId)
    • markToolCallSuspended

      public void markToolCallSuspended(String toolCallId)
    • addInterrupt

      public void addInterrupt(AguiEvent.Interrupt interrupt)
    • getPendingInterrupts

      public List<AguiEvent.Interrupt> getPendingInterrupts()
    • finishPendingEvents

      public List<AguiEvent> finishPendingEvents()
    • isExternalToolCall

      public boolean isExternalToolCall(String toolCallId)
      Whether the started tool call resolves to an external tool.

      External tools execute outside the framework (e.g. frontend-provided or schema-only tools) and need TOOL_CALL_ARGS delivered to the client even when emitToolCallArgs is disabled. Streaming argument chunks often use a placeholder name such as __fragment__, so the real name recorded on ToolCallStart is resolved by toolCallId rather than read from the delta.