Skip to content

Commit 4237150

Browse files
committed
Polish Agentic result display
1 parent 260bda9 commit 4237150

4 files changed

Lines changed: 69 additions & 12 deletions

File tree

app/hermes-agentic-result.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export function formatAgenticTaskResult(response) {
2+
const text = String(response?.text || "").trim();
3+
const activity = (response?.events || [])
4+
.filter((event) => event?.type === "tool_activity")
5+
.map((event) => String(event.payload || "").trim())
6+
.filter(Boolean)
7+
.filter((payload) => !text || !/\bin_progress\b/i.test(payload));
8+
9+
if (text && activity.length > 0) {
10+
return `${text}\n\nTool activity:\n${activity.join("\n\n")}`;
11+
}
12+
if (text) {
13+
return text;
14+
}
15+
if (activity.length > 0) {
16+
return `Tool activity:\n${activity.join("\n\n")}`;
17+
}
18+
return "";
19+
}

app/hermes-agentic-result.test.mjs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import assert from "node:assert/strict";
2+
import test from "node:test";
3+
4+
import { formatAgenticTaskResult } from "./hermes-agentic-result.js";
5+
6+
test("completed agentic responses show final text before tool activity", () => {
7+
const output = formatAgenticTaskResult({
8+
text: "Latest Ollama release: v0.30.10",
9+
events: [
10+
{
11+
type: "tool_activity",
12+
payload: "browser_open: completed\nhttps://github.com/ollama/ollama/releases/tag/v0.30.10"
13+
}
14+
]
15+
});
16+
17+
assert.match(output, /^Latest Ollama release: v0\.30\.10/);
18+
assert.match(output, /Tool activity:/);
19+
assert.match(output, /browser_open: completed/);
20+
});
21+
22+
test("completed agentic responses hide stale in progress tool lines", () => {
23+
const output = formatAgenticTaskResult({
24+
text: "Latest Ollama release: v0.30.10",
25+
events: [
26+
{
27+
type: "tool_activity",
28+
payload: "browser_open: in_progress\nhttps://github.com/ollama/ollama/releases/latest"
29+
}
30+
]
31+
});
32+
33+
assert.equal(output, "Latest Ollama release: v0.30.10");
34+
});
35+
36+
test("agentic progress still shows tool activity before final text exists", () => {
37+
const output = formatAgenticTaskResult({
38+
text: "",
39+
events: [
40+
{
41+
type: "tool_activity",
42+
payload: "browser_open: in_progress"
43+
}
44+
]
45+
});
46+
47+
assert.equal(output, "Tool activity:\nbrowser_open: in_progress");
48+
});

app/main.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
shouldSubmitComposer
2626
} from "./composer-state.js";
2727
import { formatAgenticHermesPrompt } from "./hermes-agentic-prompt.js";
28+
import { formatAgenticTaskResult } from "./hermes-agentic-result.js";
2829
import { formatHermesMode, parseHermesControlCommand } from "./hermes-mode.js";
2930
import { classifyHermesRoute } from "./hermes-routing.js";
3031
import { shouldClearInputOnSubmit } from "./input-state.js";
@@ -797,17 +798,6 @@ function formatRiskClass(value) {
797798
return labels[String(value || "")] || "Confirmation required";
798799
}
799800

800-
function formatAgenticTaskResult(response) {
801-
const activity = (response?.events || [])
802-
.filter((event) => event?.type === "tool_activity")
803-
.map((event) => String(event.payload || "").trim())
804-
.filter(Boolean);
805-
if (activity.length === 0) {
806-
return String(response?.text || "");
807-
}
808-
return `Tool activity:\n${activity.join("\n\n")}\n\nResult:\n${response.text}`;
809-
}
810-
811801
function formatImageGenerationResult(response) {
812802
const provenance = response?.provenance || {};
813803
return [

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"test:voice": "node --test app/voice-state.test.mjs app/attachment-state.test.mjs app/attachment-url.test.mjs app/browser-preview.test.mjs app/composer-state.test.mjs app/dynamic-context-state.test.mjs app/hermes-agentic-prompt.test.mjs app/hermes-routing.test.mjs app/hermes-mode.test.mjs app/panic-state.test.mjs app/speech-chunks.test.mjs app/speech-output.test.mjs app/staging-state.test.mjs app/input-state.test.mjs",
7+
"test:voice": "node --test app/voice-state.test.mjs app/attachment-state.test.mjs app/attachment-url.test.mjs app/browser-preview.test.mjs app/composer-state.test.mjs app/dynamic-context-state.test.mjs app/hermes-agentic-prompt.test.mjs app/hermes-agentic-result.test.mjs app/hermes-routing.test.mjs app/hermes-mode.test.mjs app/panic-state.test.mjs app/speech-chunks.test.mjs app/speech-output.test.mjs app/staging-state.test.mjs app/input-state.test.mjs",
88
"test:python": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/test_python.ps1",
99
"test:site": "node scripts/validate_site.mjs",
1010
"tauri": "tauri",

0 commit comments

Comments
 (0)