Show sessions in Dex Web
查看 MarkdownDex Web draws a Flow and offers its Actions from a Flow Definition Graph. dexcli visualize cannot read the session Flow, because the Flow lives in the agents package and each application chooses its Flow type. The Python and TypeScript packages ship the session graph instead.
Upload the session graph from the Worker
Since 0.5.0. With server-zd 0.1.26 or later, the Worker uploads the graph to the Dex Server when it starts, and Dex Web reads it from there. Pass the document that session_flow_definition_document (Python) or sessionFlowDefinitionDocument (TypeScript) returns for each agent, with the agent's Flow type and the permission its Actions require, such as SupportAgent and support-agent.operate. Python takes it in WorkerOptions.flow_definitions, and TypeScript in WorkerOptions.flowDefinitions.
The Worker uploads only the Flow types it registers. A failed upload, such as on an older server, logs a warning, and the Worker still starts. See Flow definitions in the Python and TypeScript Worker references.
The document's generation time is the time the graph template last changed, the same in both packages. Restarting a Worker writes nothing, and Workers of an upgraded package replace the graph. The server keeps a stored graph whose generation time is the same or later, so changing only the permission does not replace it. To change the permission, upload the new document once with force, through upload_flow_definitions or uploadFlowDefinitions on the Client.
The Dex Agents CLI commands also upload the graph of their session Flow type when they start. Their Actions require the permission dex-agents-cli.operate.
Render the session graph
For a server older than 0.1.26, render the graph to a file instead. Render it once for each agent, with the agent's Flow type and the permission its Actions require:
dex-agents-session-graph --flow-type SupportAgent --permission support-agent.operate \
--out definitions/support-agent.json
Both packages install the dex-agents-session-graph command, and both write the same bytes. In code, call render_session_flow_graph in Python or renderSessionFlowGraph in TypeScript. Point Dex Web at the directory:
dex-web --flow-rendering-dir ./definitions
On a development machine, dexcli dev --flow-rendering-dir ./definitions does the same. Render the files in the build or deployment step that ships the Workers, and mount the directory into Dex Web. Dex Web reads the directory when it starts, so restart it after a file changes. Render the files again after you upgrade the agents packages.
What Dex Web shows
The graph shows every session Step, its wait conditions, the RPCs, and the Channels between them. It leaves out Attribute reads and writes. Dex Web offers four Actions: resolve_interrupt, answer_question, steer_user_message, and cancel_turn. Each takes its request fields as input, such as the interrupt ID and the decision, and requires the permission you chose. The Actions have no condition, because each RPC checks the session state itself. Dex Web offers all four while the session runs, and an RPC that does not apply returns false. Read the interrupt ID from PendingInterrupts in the run's state, or from the session snapshot.
The run page of a session also has an Agent session tab. It shows the conversation with each tool call where the agent made it, one approval card for each pending call, and a message box with Steer and Stop turn. The tab reads the session's Attributes directly, so it still shows the session while its Workers are down. It can also edit the session's settings and start a new session with a first message and settings. See Agent session view.
The session declares no Summary or Display fields, so Dex Web shows a session without calling a Worker. Actions still need a Worker.
Dex Web shows an Action form only to a user Working as its permission. The session Actions have no condition, so Working as hides no session of the agent. It lists every session whose Flow type offers the permission.
The agent mode of Work Queue lists the sessions that wait for a person, grouped by agent, and answers them in its side panel. See Agent inbox. A session appears there only while its Flow searches by active Step type, which start_session turns on. See Find sessions that need a person.