fix(agent): stabilize large tool results
Generic Container CI/CD / test-build-publish (push) Successful in 1m53s
Agent CI/CD v2 / build-test-publish-and-deploy (push) Successful in 1m53s

This commit is contained in:
2026-08-25 12:02:48 +08:00
parent 774f39cbbe
commit 004c9bb72d
17 changed files with 721 additions and 62 deletions
+13 -11
View File
@@ -233,7 +233,8 @@ app.post("/internal/tools/tjwater-cli-call", async (req, res) => {
executeCliCommand(activeContext, command, timeoutSec, {
apiBaseUrl: config.TJWATER_API_BASE_URL,
cliPath: config.TJWATER_CLI_PATH,
maxOutputBytes: config.MAX_INLINE_RESULT_BYTES,
maxStderrBytes: config.MAX_CLI_STDERR_BYTES,
maxStdoutBytes: config.MAX_CLI_OUTPUT_BYTES,
}),
);
} catch (error) {
@@ -278,7 +279,7 @@ app.post("/internal/tools/tjwater-cli-call", async (req, res) => {
summary: "CLI 输出超过安全限制",
error: {
code: "OUTPUT_LIMIT_EXCEEDED",
message: `${result.exceededStream ?? "output"} exceeded ${config.MAX_INLINE_RESULT_BYTES} bytes`,
message: `${result.exceededStream ?? "output"} exceeded ${config.MAX_CLI_OUTPUT_BYTES} bytes`,
retryable: false,
},
});
@@ -307,16 +308,17 @@ app.post("/internal/tools/tjwater-cli-call", async (req, res) => {
return;
}
try {
res.json(JSON.parse(result.stdout));
} catch {
res.json({
ok: true,
schema_version: "tjwater-cli/v1",
raw: result.stdout,
stderr: result.stderr || undefined,
});
if (result.stdout.trim()) {
res.status(200).type("application/json").send(result.stdout);
return;
}
res.json({
ok: true,
schema_version: "tjwater-cli/v1",
raw: "",
stderr: result.stderr || undefined,
stderr_truncated: result.stderrTruncated || undefined,
});
});
app.post("/internal/tools/store-render-ref", async (req, res) => {