Added button to rotate api key. This is required for better UX, now user has to remake agent if key is lost.
A migration is needed to keep track of proper usage + to not leave any orphan entries.
* fix: replace print() with logger in classic_rag.py and encryption.py
Three print() calls bypassed the structured logging system, risking
exposure of rephrased user queries and credential error details to
unmanaged stdout. Replace with logger.debug() / logger.warning() and
add a module-level logger to both files. Also migrate all bare
logging.xxx() calls in classic_rag.py to the module-level logger for
consistency.
* (chore:encryption.py) ruff
---------
Co-authored-by: ManishMadan2882 <manishmadan321@gmail.com>
* docs: fix grammatical parallelism and clean up markdown links in README
- Fixed grammatical parallelism in QuickStart ("build" -> "building" and added "are" to "Five options are available").
- Converted raw HTML tags to clean Markdown links in Project Structure.
- Fixed capitalization for "React widget".
* docs(readme): update extensions description in Project Structure
Project Structure: Updated the extensions/ directory description in README.md to accurately reference Chatwoot and the React widget (removing the outdated Discord bot reference per maintainer feedback).Project Structure Links: Converted raw HTML links to clean Markdown link syntax for better maintainability and readability.QuickStart Grammar Fixes: Corrected grammatical parallelism ("build" $\rightarrow$ "building" and added "are" to "Five options are available").
Address Copilot review on #2600:
- pass a useCallback handler to useOutsideAlerter so the global mousedown
listener isn't torn down/re-added on every WorkflowBuilder render
- remove trailing spaces after {displayName} in AgentPageHeader
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Token accounting:
- Drain each tool round's provider stream to exhaustion before running
tools and recursing, so the usage decorator persists exactly one
token_usage row per LLM call, at call end. Previously every round's
generator was abandoned mid-iteration and flushed together at request
teardown, writing N near-identical rows stamped with the final
round's provider counts (duplicate billing).
- Consume the Chat Completions include_usage terminal chunk (it arrives
after finish_reason and was never read) so streamed calls record
provider-exact token counts instead of tiktoken estimates.
- Claim provider-reported usage once per call (_last_usage_claimed) so
a late-finalized generator can never adopt another call's counts.
Oversized-context guards:
- Enforce Responses API function_call/function_call_output pairing in
the input builder (drop unpaired items; bypassed for store-mode
previous_response_id chaining where calls are matched server-side).
- Hard pre-send context gate: shrink oversized tool results and refuse
payloads that cannot fit the model's window before dispatch, so a
hopeless request is never sent or billed.
- Cap a single tool result entering the LLM context
(TOOL_RESULT_MAX_TOKENS, default 20000); the tool journal and
persistence keep the full result. Applied on the resume/continuation
path too.
- Skip the fallback attempt when the payload cannot fit the fallback
model's context window (10% estimation slack).
- Compression: never save a compression point that does not reduce
tokens; bound oversized verbatim fields kept after a compression
point (COMPRESSION_RECENT_FIELD_MAX_TOKENS, default 8000).
Robustness fixes from review:
- Google parallel function calls: complete index-less ToolCalls are no
longer merged into one another (dict arguments raised TypeError on
+=; second call could execute with the first call's arguments).
- Trailing-frame failures after a delivered answer no longer error the
stream or restream the whole answer from the fallback
(_stream_reached_finish).
- In-memory compression falls back to minimal pruning when the summary
is not smaller than the original.
- keep<=0 guard in the middle-truncation helpers (a tiny cap returned
marker + full text).
Frontend: tooltip on the Analytics tokens stat card explaining that
agent tool loops re-send conversation context on every step.