From 9b168fba7bbd4d8931ca5d5afa285448c574c429 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 25 Jun 2026 17:41:42 -0400 Subject: [PATCH] refac --- .../src/lib/components/chat/AssistantMessage.svelte | 13 ------------- cptr/utils/agents/codex.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/cptr/frontend/src/lib/components/chat/AssistantMessage.svelte b/cptr/frontend/src/lib/components/chat/AssistantMessage.svelte index 36c920b..5d52895 100644 --- a/cptr/frontend/src/lib/components/chat/AssistantMessage.svelte +++ b/cptr/frontend/src/lib/components/chat/AssistantMessage.svelte @@ -280,18 +280,6 @@ return cleaned.replace(/\n{3,}/g, '\n\n').trim(); } - function isPseudoAgentMessageTool(item: any): boolean { - const title = String(item?.arguments?.title || item?.arguments?.item?.type || '').toLowerCase(); - return ( - item?.name === 'agent_tool' && - (title === 'usermessage' || - title === 'agentmessage' || - title === 'assistantmessage' || - title === 'assistant message' || - title === 'user message') - ); - } - const displayItems = $derived.by((): DisplayItem[] => { if (!output?.length) return []; @@ -327,7 +315,6 @@ for (const item of output) { if (item.type === 'function_call') { - if (isPseudoAgentMessageTool(item)) continue; ensureGroup(); currentGroup!.entries.push(item); currentGroup!.calls.push(item); diff --git a/cptr/utils/agents/codex.py b/cptr/utils/agents/codex.py index a998c95..91434e4 100644 --- a/cptr/utils/agents/codex.py +++ b/cptr/utils/agents/codex.py @@ -155,6 +155,17 @@ def _sandbox_for_approval(value: str) -> str: return "workspace-write" +def _codex_turn_options(chat_params: dict[str, Any]) -> dict[str, str]: + options: dict[str, str] = {} + effort = chat_params.get("reasoningEffort") or chat_params.get("reasoning_effort") + if isinstance(effort, str) and effort.strip(): + options["effort"] = effort.strip() + service_tier = chat_params.get("serviceTier") or chat_params.get("service_tier") + if isinstance(service_tier, str) and service_tier.strip(): + options["serviceTier"] = service_tier.strip() + return options + + def _tool_from_item_event(method: str, params: dict[str, Any]) -> AgentToolUpdate | None: if method not in {"item/started", "item/completed"}: return None @@ -262,6 +273,7 @@ async def run_codex_agent( { "threadId": thread_id, "input": turn_input, + **_codex_turn_options(chat_params), }, ) turn = turn_response.get("result", {}).get("turn", {})