refactor(coding-agent): removed configurable read timeout and standardized URL fetch timeout

- Removed the read CLI argument and tool schema field so read requests no longer accept custom timeouts.
- Updated URL read handling to stop forwarding timeout values and execute URL reads without a timeout parameter.
- Standardized URL read fetching to a fixed 30-second timeout and dropped timeout metadata from URL call rendering.
This commit is contained in:
can1357
2026-05-07 05:37:24 +02:00
parent 5df31b37d1
commit fdc3fe1196
5 changed files with 12 additions and 22 deletions
+1 -2
View File
@@ -15,7 +15,6 @@ import { renderError } from "../tools/tool-errors";
export interface ReadCommandArgs {
path: string;
timeout?: number;
}
export async function runReadCommand(cmd: ReadCommandArgs): Promise<void> {
@@ -38,7 +37,7 @@ export async function runReadCommand(cmd: ReadCommandArgs): Promise<void> {
const tool = wrapToolWithMetaNotice(new ReadTool(session));
try {
const result = await tool.execute("omp-read", { path: cmd.path, timeout: cmd.timeout });
const result = await tool.execute("omp-read", { path: cmd.path });
for (const block of result.content) {
if (block.type === "text") {
+2 -7
View File
@@ -1,7 +1,7 @@
/**
* Show what the read tool will return for a given path.
*/
import { Args, Command, Flags } from "@oh-my-pi/pi-utils/cli";
import { Args, Command } from "@oh-my-pi/pi-utils/cli";
import { type ReadCommandArgs, runReadCommand } from "../cli/read-cli";
import { initTheme } from "../modes/theme/theme";
@@ -15,10 +15,6 @@ export default class Read extends Command {
}),
};
static flags = {
timeout: Flags.integer({ description: "Request timeout in seconds (URLs only)" }),
};
static examples = [
"omp read src/foo.ts",
"omp read src/foo.ts:50-100",
@@ -29,10 +25,9 @@ export default class Read extends Command {
];
async run(): Promise<void> {
const { args, flags } = await this.parse(Read);
const { args } = await this.parse(Read);
const cmd: ReadCommandArgs = {
path: args.path ?? "",
timeout: flags.timeout,
};
await initTheme();
await runReadCommand(cmd);
@@ -7,7 +7,6 @@ The `read` tool is multi-purpose and more capable than it looks — inspects fil
## Parameters
- `path` — file path or URL (required). Append `:<sel>` for line ranges or raw mode (for example `src/foo.ts:50-200` or `src/foo.ts:raw`).
- `timeout` — seconds, for URLs only
## Selectors
+6 -7
View File
@@ -1220,13 +1220,13 @@ function cacheReadUrlEntry(session: ToolSession, requestedUrl: string, raw: bool
async function buildReadUrlCacheEntry(
session: ToolSession,
params: { path: string; timeout?: number; raw?: boolean },
params: { path: string; raw?: boolean },
signal?: AbortSignal,
options?: { ensureArtifact?: boolean },
): Promise<ReadUrlCacheEntry> {
const { path: url, timeout: rawTimeout = 20, raw = false } = params;
const { path: url, raw = false } = params;
const effectiveTimeout = clampTimeout("fetch", rawTimeout);
const effectiveTimeout = clampTimeout("fetch", 30);
if (signal?.aborted) {
throw new ToolAbortError();
@@ -1254,7 +1254,7 @@ async function buildReadUrlCacheEntry(
export async function loadReadUrlCacheEntry(
session: ToolSession,
params: { path: string; timeout?: number; raw?: boolean },
params: { path: string; raw?: boolean },
signal?: AbortSignal,
options?: { ensureArtifact?: boolean; preferCached?: boolean },
): Promise<ReadUrlCacheEntry> {
@@ -1291,7 +1291,7 @@ function buildUrlReadOutput(result: FetchRenderResult, content: string): string
export async function executeReadUrl(
session: ToolSession,
params: { path: string; timeout?: number; raw?: boolean },
params: { path: string; raw?: boolean },
signal?: AbortSignal,
): Promise<AgentToolResult<ReadUrlToolDetails>> {
let cacheEntry = await loadReadUrlCacheEntry(session, params, signal, { preferCached: true });
@@ -1345,7 +1345,7 @@ function countNonEmptyLines(text: string): number {
/** Render URL read call (URL preview) */
export function renderReadUrlCall(
args: { path?: string; url?: string; timeout?: number; raw?: boolean },
args: { path?: string; url?: string; raw?: boolean },
_options: RenderResultOptions,
uiTheme: Theme = theme,
): Component {
@@ -1355,7 +1355,6 @@ export function renderReadUrlCall(
const description = `${domain}${path ? ` ${path}` : ""}`.trim();
const meta: string[] = [];
if (args.raw) meta.push("raw");
if (args.timeout !== undefined) meta.push(`timeout:${args.timeout}s`);
const text = renderStatusLine({ icon: "pending", title: "Read", description, meta }, uiTheme);
return new Text(text, 0, 0);
}
+3 -5
View File
@@ -419,7 +419,6 @@ const readSchema = Type.Object({
description: 'path or url; append :<sel> for line ranges or raw mode (e.g. "src/foo.ts:50-100")',
examples: ["src/foo.ts", "src/foo.ts:50-100", "https://example.com:L1-L40"],
}),
timeout: Type.Optional(Type.Number({ description: "timeout in seconds", default: 20 })),
});
export type ReadToolInput = Static<typeof readSchema>;
@@ -1085,7 +1084,7 @@ export class ReadTool implements AgentTool<typeof readSchema, ReadToolDetails> {
_onUpdate?: AgentToolUpdateCallback<ReadToolDetails>,
_toolContext?: AgentToolContext,
): Promise<AgentToolResult<ReadToolDetails>> {
let { path: readPath, timeout } = params;
let { path: readPath } = params;
if (readPath.startsWith("file://")) {
readPath = expandPath(readPath);
}
@@ -1099,7 +1098,7 @@ export class ReadTool implements AgentTool<typeof readSchema, ReadToolDetails> {
if (parsedUrlTarget.offset !== undefined || parsedUrlTarget.limit !== undefined) {
const cached = await loadReadUrlCacheEntry(
this.session,
{ path: parsedUrlTarget.path, timeout, raw: parsedUrlTarget.raw },
{ path: parsedUrlTarget.path, raw: parsedUrlTarget.raw },
signal,
{
ensureArtifact: true,
@@ -1112,7 +1111,7 @@ export class ReadTool implements AgentTool<typeof readSchema, ReadToolDetails> {
entityLabel: "URL output",
});
}
return executeReadUrl(this.session, { path: parsedUrlTarget.path, timeout, raw: parsedUrlTarget.raw }, signal);
return executeReadUrl(this.session, { path: parsedUrlTarget.path, raw: parsedUrlTarget.raw }, signal);
}
// Handle internal URLs (agent://, artifact://, memory://, skill://, rule://, local://, mcp://)
@@ -1569,7 +1568,6 @@ interface ReadRenderArgs {
path?: string;
file_path?: string;
sel?: string;
timeout?: number;
// Legacy fields from old schema — tolerated for in-flight tool calls during transition
offset?: number;
limit?: number;