fix(agent): stabilize large tool results
This commit is contained in:
+13
-11
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user