Skip to content

Enhance default interaction function and improve token metrics handling#18

Merged
nmaguiar merged 1 commit intomainfrom
codex/implement-dynamic-task-progress-updates
Oct 12, 2025
Merged

Enhance default interaction function and improve token metrics handling#18
nmaguiar merged 1 commit intomainfrom
codex/implement-dynamic-task-progress-updates

Conversation

@nmaguiar
Copy link
Copy Markdown
Contributor

This pull request improves the way token usage statistics are calculated and logged throughout the mini-a.js codebase. The main change is the introduction of a new helper method for robustly computing total token counts, which is now used consistently across summary, response, and fallback handling logic. Additionally, the interaction logging function is made more flexible, and a method to retrieve the instance ID is added.

Token statistics calculation and logging:

  • Added a new helper method _getTotalTokens to compute total token usage from stats objects, handling cases where total_tokens may be missing and falling back to summing prompt_tokens and completion_tokens. This method is now used in all places where token metrics are updated, improving consistency and robustness.
  • Updated all metric logging in _startInternal and _runChatbotMode to use _getTotalTokens, ensuring that token counts are always computed accurately for normal, low-cost, and fallback model responses. [1] [2] [3] [4] [5] [6]

Interaction logging improvements:

  • Enhanced defaultInteractionFn to accept an optional callback function (cFn) for custom logging behavior, with a default that preserves previous functionality. [1] [2]

API enhancement:

  • Added a new method getId to retrieve the unique ID of a MiniA instance.

@nmaguiar nmaguiar self-assigned this Oct 12, 2025
@nmaguiar nmaguiar added the enhancement New feature or request label Oct 12, 2025
@nmaguiar nmaguiar merged commit ea09ae0 into main Oct 12, 2025
@nmaguiar nmaguiar deleted the codex/implement-dynamic-task-progress-updates branch October 12, 2025 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant