Skip to content

fix(agents): remove unreachable recordUsage code - #14794

Open
zsxh1990 wants to merge 1 commit into
danny-avila:mainfrom
zsxh1990:fix/agents-unreachable-recordusage
Open

fix(agents): remove unreachable recordUsage code#14794
zsxh1990 wants to merge 1 commit into
danny-avila:mainfrom
zsxh1990:fix/agents-unreachable-recordusage

Conversation

@zsxh1990

Copy link
Copy Markdown

Problem

The recordUsage call in agents/errors.js was unreachable because:

  1. run variable was declared but never assigned (let run;)
  2. run.usage and run.model would always throw TypeError: Cannot read properties of undefined
  3. The catch block swallowed the error with misleading log message "Error fetching or processing run"

This was a copy/paste regression from assistants/errors.js where run is properly assigned via openai.beta.threads.runs.retrieve(). Since agents have no equivalent API, the entire block was dead code.

Fix

Removed the unreachable code block and unused recordUsage import.

Closes #14792

The recordUsage call in agents/errors.js was unreachable because:
1. `run` variable was declared but never assigned
2. `run.usage` and `run.model` would always throw TypeError
3. The catch block swallowed the error with misleading log message

This was a copy/paste regression from assistants/errors.js where `run` is
properly assigned via `openai.beta.threads.runs.retrieve()`. Since agents
have no equivalent API, the entire block was dead code.

Closes danny-avila#14792

Signed-off-by: zsxh1990 <zsxh1990@users.noreply.github.com>
Signed-off-by: zsxh1990 <445655361@qq.com>
@zsxh1990

Copy link
Copy Markdown
Author

Hi! All CI checks pass. Let me know if you'd like any changes 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

agents/errors.js: recordUsage is unreachable — run is declared but never assigned

1 participant