lewtun HF Staff OpenAI Codex commited on
Commit
beb0c92
·
unverified ·
1 Parent(s): 60f7188

Fix stale tool error badges (#247)

Browse files

* Fix GPU sandbox hardware OAuth failure

Co-authored-by: OpenAI Codex <codex@openai.com>

* Address sandbox sleep-time review

Co-authored-by: OpenAI Codex <codex@openai.com>

* Fix stale tool error badges

Co-authored-by: OpenAI Codex <codex@openai.com>

---------

Co-authored-by: OpenAI Codex <codex@openai.com>

frontend/src/components/Chat/ToolCallGroup.tsx CHANGED
@@ -784,12 +784,15 @@ export default function ToolCallGroup({ tools, approveTools }: ToolCallGroupProp
784
  // Persist error states when tools error
785
  useEffect(() => {
786
  for (const tool of tools) {
787
- const currentlyHasError = tool.state === 'output-error';
788
  const persistedError = getToolError(tool.toolCallId);
789
 
790
- // Persist error state if we detect it and haven't already
 
791
  if (currentlyHasError && !persistedError) {
792
  setToolError(tool.toolCallId, true);
 
 
793
  }
794
  }
795
  }, [tools, setToolError, getToolError]);
 
784
  // Persist error states when tools error
785
  useEffect(() => {
786
  for (const tool of tools) {
787
+ const currentlyHasError = tool.state === 'output-error' && !isCancelledTool(tool);
788
  const persistedError = getToolError(tool.toolCallId);
789
 
790
+ // Persist real error states across refresh. Clear stale persisted errors
791
+ // once the SDK reports a successful output for the same tool call.
792
  if (currentlyHasError && !persistedError) {
793
  setToolError(tool.toolCallId, true);
794
+ } else if (tool.state === 'output-available' && persistedError) {
795
+ setToolError(tool.toolCallId, false);
796
  }
797
  }
798
  }, [tools, setToolError, getToolError]);
frontend/src/store/agentStore.ts CHANGED
@@ -518,7 +518,12 @@ export const useAgentStore = create<AgentStore>()((set, get) => ({
518
 
519
  setToolError: (toolCallId, hasError) => {
520
  set((state) => {
521
- const updated = { ...state.toolErrors, [toolCallId]: hasError };
 
 
 
 
 
522
  saveToolErrors(updated);
523
  return { toolErrors: updated };
524
  });
 
518
 
519
  setToolError: (toolCallId, hasError) => {
520
  set((state) => {
521
+ const updated = { ...state.toolErrors };
522
+ if (hasError) {
523
+ updated[toolCallId] = true;
524
+ } else {
525
+ delete updated[toolCallId];
526
+ }
527
  saveToolErrors(updated);
528
  return { toolErrors: updated };
529
  });