mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-11 08:42:11 +00:00
fix(desktop): drop noisy "returned N items / empty object" stub strings
When a tool returns nothing useful, the row should be silent — the title
("Search Files", etc.) already tells the user what happened. Counting the
fields in an opaque payload is engineer-noise.
`formatToolResultSummary` and `minimalValueSummary` now return '' for
empty arrays / records / unrecognized values; tool-fallback already hides
the detail section when its body is empty.
This commit is contained in:
parent
f08cc6bbeb
commit
4afbdf58b3
2 changed files with 13 additions and 36 deletions
|
|
@ -833,30 +833,14 @@ export function inlineDiffFromResult(result: unknown): string {
|
|||
return typeof value === 'string' ? stripInlineDiffChrome(value) : ''
|
||||
}
|
||||
|
||||
// Falls back to a string only when there's something concrete to render —
|
||||
// counts of opaque items/fields are noise, not signal.
|
||||
function minimalValueSummary(value: unknown): string {
|
||||
if (value == null) {
|
||||
return ''
|
||||
}
|
||||
if (value == null) return ''
|
||||
if (typeof value === 'string') return value
|
||||
if (typeof value === 'number' || typeof value === 'boolean') return String(value)
|
||||
|
||||
if (typeof value === 'string') {
|
||||
return value
|
||||
}
|
||||
|
||||
if (typeof value === 'number' || typeof value === 'boolean') {
|
||||
return String(value)
|
||||
}
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
return value.length ? `Returned ${value.length} items.` : 'No items returned.'
|
||||
}
|
||||
|
||||
if (isRecord(value)) {
|
||||
const count = Object.keys(value).length
|
||||
|
||||
return count ? `Returned object with ${count} fields.` : 'Returned an empty object.'
|
||||
}
|
||||
|
||||
return String(value)
|
||||
return ''
|
||||
}
|
||||
|
||||
function fallbackDetailText(args: unknown, result: unknown): string {
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ function formatFieldValue(value: unknown, depth: number): string {
|
|||
|
||||
if (Array.isArray(v)) {
|
||||
if (!v.length) {
|
||||
return '0 items'
|
||||
return ''
|
||||
}
|
||||
const scalars = v.map(summarizeScalar).filter(Boolean)
|
||||
|
||||
|
|
@ -204,10 +204,10 @@ function formatFieldValue(value: unknown, depth: number): string {
|
|||
return clipInline(String(v))
|
||||
}
|
||||
|
||||
// "Returned N items" / "0 items" / "Returned an empty object" are all
|
||||
// noise — better to render nothing and let the title carry the signal.
|
||||
function formatArraySummary(value: unknown[], depth: number): string {
|
||||
if (!value.length) {
|
||||
return 'No items returned.'
|
||||
}
|
||||
if (!value.length) return ''
|
||||
|
||||
const max = 6
|
||||
const lines = value
|
||||
|
|
@ -216,9 +216,7 @@ function formatArraySummary(value: unknown[], depth: number): string {
|
|||
.filter(Boolean)
|
||||
.map(l => `- ${l}`)
|
||||
|
||||
if (!lines.length) {
|
||||
return `Returned ${pluralize(value.length, 'item')}.`
|
||||
}
|
||||
if (!lines.length) return ''
|
||||
|
||||
if (value.length > max) {
|
||||
const remaining = value.length - max
|
||||
|
|
@ -230,10 +228,7 @@ function formatArraySummary(value: unknown[], depth: number): string {
|
|||
|
||||
function formatRecordSummary(record: Json, depth: number): string {
|
||||
const keys = Object.keys(record)
|
||||
|
||||
if (!keys.length) {
|
||||
return 'Returned an empty object.'
|
||||
}
|
||||
if (!keys.length) return ''
|
||||
|
||||
if (depth <= 2) {
|
||||
const direct = firstString(record, ['message', 'summary', 'description', 'preview', 'text', 'content'])
|
||||
|
|
@ -261,9 +256,7 @@ function formatRecordSummary(record: Json, depth: number): string {
|
|||
}
|
||||
}
|
||||
|
||||
if (!lines.length) {
|
||||
return `Returned object with ${pluralize(keys.length, 'field')}.`
|
||||
}
|
||||
if (!lines.length) return ''
|
||||
|
||||
if (candidates.length > lines.length) {
|
||||
const remaining = candidates.length - lines.length
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue