Skip to content

Commit bb5c88f

Browse files
fix(agentforge): handle numeric strings in trace display output
Log values like latency_ms and stage_timings_ms are serialized as strings in JSON. Use is_numeric() instead of is_int() so the table and stage timing sections render correctly. Assisted-by: Claude Code
1 parent 716d0b8 commit bb5c88f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

agent-forge/scripts/show-request-traces.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function agentforge_show_traces_print_table(array $entries): void
153153
foreach ($entries as $i => $entry) {
154154
$requestId = is_string($entry['request_id'] ?? null) ? substr($entry['request_id'], 0, 12) : '';
155155
$decision = is_string($entry['decision'] ?? null) ? $entry['decision'] : '';
156-
$latency = is_int($entry['latency_ms'] ?? null) ? (string) $entry['latency_ms'] : '';
156+
$latency = is_numeric($entry['latency_ms'] ?? null) ? (string) (int) $entry['latency_ms'] : '';
157157
$model = is_string($entry['model'] ?? null) ? $entry['model'] : '';
158158
$verifier = is_string($entry['verifier_result'] ?? null) ? $entry['verifier_result'] : '';
159159
$sourceIds = is_array($entry['source_ids'] ?? null) ? (string) count($entry['source_ids']) : '0';
@@ -187,15 +187,15 @@ function agentforge_show_traces_print_stage_details(array $entries): void
187187
continue;
188188
}
189189

190-
$latency = is_int($entry['latency_ms'] ?? null) ? $entry['latency_ms'] : null;
190+
$latency = is_numeric($entry['latency_ms'] ?? null) ? (int) $entry['latency_ms'] : null;
191191
$header = sprintf("### [%d] %s", $i + 1, $requestId);
192192
if ($latency !== null) {
193193
$header .= sprintf(" — total %dms", $latency);
194194
}
195195
fwrite(STDOUT, $header . "\n");
196196

197197
foreach ($timings as $stage => $ms) {
198-
if (is_int($ms) || is_float($ms)) {
198+
if (is_numeric($ms)) {
199199
fwrite(STDOUT, sprintf(" %s: %dms\n", $stage, (int) $ms));
200200
}
201201
}

0 commit comments

Comments
 (0)