Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions agent-service/src/agent/prompts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ describe("buildSystemPrompt", () => {
expect(prompt).toContain("## R UDF Guide");
});

test("describes the dataflow block that ends each step, and no format for the conversation", () => {
// The conversation reaches the model as native messages, so the prompt describes only the one
// block the service writes: the current dataflow.
const prompt = buildSystemPrompt(makeMetadataStore(), ["Filter"]);

expect(prompt).toContain("## Current Dataflow");
expect(prompt).toContain("### Operator `<operator_id>` (<operator_type>, executed|failed|not-executed)");
expect(prompt).not.toContain("## Context Format");
expect(prompt).not.toContain("# Completed Tasks");
expect(prompt).not.toContain("# Ongoing Task");
expect(prompt).not.toContain("### Turn");
});

test("reports that no operators are available when a restricted type is absent from metadata", () => {
const prompt = buildSystemPrompt(makeMetadataStore(), ["MissingOperator"]);

Expand Down
55 changes: 3 additions & 52 deletions agent-service/src/agent/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,60 +161,11 @@ Dataflow represents data analysis as a DAG (directed acyclic graph) where:
- Each operator receives table(s) from input operator(s), processes them, and outputs a single table
- The output table can be viewed via execution, or passed to downstream operators via links

## Context Format
## Current Dataflow

Your conversation context is a single message with three top-level sections, in this order:

- \`# Completed Tasks\` — previous tasks you've already finished (omitted if none)
- \`# Ongoing Task\` — the current task, including turns you've taken so far
- \`# Current Dataflow\` — the live DAG: every operator's current state

**Overall layout:**
Before each of your steps, the conversation ends with a message that starts with \`# Current Dataflow\` (none while the workflow is empty). The system writes it, not the user, and it always shows the workflow as it is now:

\`\`\`
# Completed Tasks

## Task (completed)

### User request

<a past user question>

### Turn 1
Thought: <your reasoning from that turn>
- <toolName> (succeeded)
- Summary: <the summary you provided in the tool call>
- Output: <brief tool output>

## Task (completed)

### User request

<another past user question>

### Turn 1
...

# Ongoing Task
## Task (ongoing)

### User request

<the current user question>

### Turn 1
Thought: ...
- <toolName> (succeeded)
- Summary: ...
- Output: ...

### Turn 2
Thought: ...
- <toolName> (failed)
- Summary: ...
- Error:
<full error trace, possibly multi-line>

# Current Dataflow
## Operators

Expand All @@ -237,7 +188,7 @@ Result:

## Key Principles

- **Call tools only through the native protocol**: Invoke tools using the tool-call mechanism. Never emit \`<action>\`, \`<thought>\`, \`<operator>\`, or any other tag-like structures in your response — those shapes appear in your input to describe past turns and existing state, never in your output.
- **Call tools only through the native protocol**: Invoke tools using the tool-call mechanism. Never write a tool call, a thought or an operator as text, and never emit \`<action>\`, \`<thought>\`, \`<operator>\`, or any other tag-like structures in your response.
- **One operation per operator**: Each operator does one task (join, filter, aggregate, etc.). Use links to connect them.
- **Build incrementally**: Link new operators to existing ones. Never recreate data already in the workflow.
- **Read documentation first**: When the task mentions abstract concepts, load documentation to understand exact definitions.
Expand Down
Loading
Loading