Skip to content

Harden assistant flow and OCR input handling#5

Merged
tdtgit merged 1 commit intomainfrom
codex/review-and-improve-index.ts
Mar 27, 2026
Merged

Harden assistant flow and OCR input handling#5
tdtgit merged 1 commit intomainfrom
codex/review-and-improve-index.ts

Conversation

@tdtgit
Copy link
Copy Markdown
Owner

@tdtgit tdtgit commented Mar 27, 2026

Motivation

  • Prevent runtime failures from out-of-bounds Telegram photo access and from non-function or malformed model outputs.
  • Make the assistant flow more resilient so tool dispatch and transaction parsing don't crash the service.

Description

  • Add getLatestPhotoFileId(message) and use it in imageOcr to avoid fixed-index access like message.photo[3] and fail fast when no photo is present.
  • Replace brittle access of response.output[0] with a search for a function_call item and handle the case where the model returns no function call by returning Request completed early.
  • Use functionCall.arguments when dispatching tool handlers instead of assuming response.output[0].arguments.
  • Add defensive JSON parsing in processTransaction using try/catch around JSON.parse to log and return early on malformed model output.

Testing

  • Ran the test suite with bun test, all tests passed (3 pass, 0 fail).

Codex Task

@tdtgit tdtgit merged commit eb41ad3 into main Mar 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant