Skip to content
This repository was archived by the owner on Aug 18, 2026. It is now read-only.
This repository was archived by the owner on Aug 18, 2026. It is now read-only.

AgentResponse.chunk_type field not renamed to message_type after backend PR #795 (workbench-ui Agent mode hangs) #17

Description

@miolamio

Summary

The TypeScript client's AgentResponse interface and the agentStreaming() switch still use the legacy chunk_type field, but the backend renamed it to message_type on 2026-04-13 in trustgraph-ai/trustgraph PR #795 ("Add agent explainability instrumentation and unify envelope field naming", commit d2751553).

Effect: every released trustgraph-flow from v2.3.1 onward (including v2.3.21 and all of v2.4.x) emits agent stream frames as {message_type: "thought" | "observation" | "answer" | …, content: …}. The client's switch on resp.chunk_type falls through the default case, so callbacks (think, observe, answer) are never invoked. Consumers like workbench-ui:1.8.2 get a stream of frames that silently produce no UI updates — the Assistant Agent / Graph RAG / Document RAG modes hang on "Processing chat message…" forever even though the backend completes the request with end_of_dialog=true.

Affected files

  • src/models/messages.ts:130-154 — AgentResponse declares both chunk_type (the active field used in the switch) and message_type?: \"chunk\" | \"explain\" (the old envelope distinguisher). They now collide semantically because the backend uses message_type for the full set thought | action | observation | answer | final-answer | explain | error.
  • src/socket/trustgraph-socket.ts:1400, 1406, 1426 — agentStreaming():
    • error check: `if (resp.chunk_type === "error" || resp.error)`
    • explain branch: `if ((resp.chunk_type === "explain" || resp.message_type === "explain") …)`
    • main switch: `switch (resp.chunk_type) { case "thought": … case "answer": case "final-answer": … }`

Backend evidence

Backend trustgraph-base/trustgraph/messaging/translators/agent.py:

def encode(self, obj: AgentResponse) -> Dict[str, Any]:
    result = {}
    if obj.message_type:
        result[\"message_type\"] = obj.message_type
    ...

Backend trustgraph-base/trustgraph/schema/services/agent.py:

@dataclass
class AgentResponse:
    message_type: str = \"\"  # \"thought\", \"action\", \"observation\", \"answer\", \"explain\", \"error\"
    ...

Grep across trustgraph-ai/trustgraph master: chunk_type is absent from all .py sources; only present in two design-doc translations under docs/tech-specs/{he,sw}/*.md.

Reproduction

  1. Deploy trustgraph/trustgraph-flow:2.3.21 (post-rename) + trustgraph/workbench-ui:1.8.2 (bundles @trustgraph/client@1.7.x pre-rename).
  2. Open Workbench → Assistant → switch mode to Agent → send any question.
  3. Browser shows "Processing chat message…" indefinitely. Browser DevTools WS frames show 100+ messages each with {message_type: ...} but no chunk_type field. Server-side gateway logs show the agent completed with end_of_dialog=true.

Suggested fix

Rename chunk_type → message_type consistently across AgentResponse and agentStreaming(), and drop the now-redundant message_type?: \"chunk\" | \"explain\" slot from AgentResponse (the values fold into the same union).

Minimal diff (verified locally — full test suite (66 tests) passes, typecheck clean):

```diff
--- a/src/models/messages.ts
+++ b/src/models/messages.ts
@@ export interface AgentResponse {

  • // Streaming response format (new protocol)
  • chunk_type?: "thought" | "action" | "observation" | "answer" | "final-answer" | "explain" | "error";
  • // Streaming response format — unified envelope field (trustgraph PR #795)
  • message_type?: "thought" | "action" | "observation" | "answer" | "final-answer" | "explain" | "error";
    message_id?: string;
    …
  • // Explainability fields
  • message_type?: "chunk" | "explain";
  • // Explainability fields (carried when message_type === "explain")
    explain_id?: string;
    explain_graph?: string;
    explain_triples?: Triple[];
    }
    ```

```diff
--- a/src/socket/trustgraph-socket.ts
+++ b/src/socket/trustgraph-socket.ts
@@

  •  if (resp.chunk_type === \"error\" || resp.error) {
    
  •  if (resp.message_type === \"error\" || resp.error) {
       error(resp.error?.message || \"Unknown agent error\");
       return true;
     }
    
  •  if ((resp.chunk_type === \"explain\" || resp.message_type === \"explain\") && resp.explain_id && resp.explain_graph) {
    
  •  if (resp.message_type === \"explain\" && resp.explain_id && resp.explain_graph) {
       …
     }
    
  •  switch (resp.chunk_type) {
    
  •  switch (resp.message_type) {
       case \"thought\": …
       case \"observation\": …
       case \"answer\":
       case \"final-answer\": …
       case \"action\": …
     }
    

```

Workaround

We are running a locally-built @trustgraph/client with the rename and a custom workbench-ui:1.8.2-msgtype image rebuilt from sources — happy to upstream as a PR if it'd help.

Refs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions