Bedrock replies stop at 1,024 tokens and a cut-off one is passed on as complete

A LangGraph, FastAPI and Streamlit template for agent services that builds the model for each of its many providers in one place.
Audited with leanprompt 0.1.0-dev.15
Estimates, not measurements. Every figure on this page is an estimate from reading the code, not a measurement of the app in use.
- Repository
- JoshuaC215/agent-service-toolkit
- Commit audited
3d77131- leanprompt version
- 0.1.0-dev.15
- Audit date
- Status
- The maintainers have been told about this audit; no response yet.
- Maintainers
- the issue
- How it ran
- Unattended audit: nobody was asked during the run, so priority, volume and prices were left open; the questions for the owner are listed at the end.
leanprompt read the code at commit 3d77131 and found 0 places where its LLM calls could use fewer tokens, plus 2 other problems, not scored. Static score: 100 of 100 (an estimate from the findings). The code may have changed since.
Findings
No open findings.
Other problems the audit found
Problems read in the code that cost no tokens of their own, such as a cost meter or an error path. Not scored.
-
Bedrock replies stop at 1,024 tokens; a cut-off reply is passed on as complete
src/core/llm.py:120·LP-GE-12Read the finish reason before using an answer · severity highWhat happens. ChatBedrock(model=...) sets no max_tokens. In the locked langchain-aws 1.9.0 an Anthropic model on ChatBedrock uses InvokeModel, whose adapter sends max_tokens=1024 when none is given (llms/bedrock.py:389-392); the Anthropic branch at llm.py:110 gets the model's own limit (128000 for claude-haiku-5-5 in langchain-anthropic 1.7.6). Checked offline with a stub client: invoke and stream both send 1024. Nothing in src/ reads stop_reason, so a cut-off answer is saved as finished.
The change. Pass an explicit limit in the AWS branch (for example ChatBedrock(model=..., max_tokens=<limit the maintainers choose>)) and surface a stop_reason of max_tokens (response_metadata) to the client instead of treating the message as complete.
To check. Build get_model(AWSModelName.BEDROCK_HAIKU) with a stub boto client that records the InvokeModel body: max_tokens is 1024 today and the chosen limit after the change.
-
The current date in three system prompts is fixed at server start
src/agents/research_assistant.py:39What happens. current_date is evaluated once at import (research_assistant.py:39, rag_assistant.py:33, github_mcp_agent.py:17) and baked into a module-level f-string that wrap_model reuses for every request (research_assistant.py:54-60). The service is a long-running process, so after the first midnight the default agent states the wrong day. docs/RAG_Assistant.md:40-42 teaches the same pattern.
The change. Build the date inside the preprocessor lambda (or a small function called from it) so each request gets the current date; the day-level string keeps the prompt prefix stable within a day.
To check. Freeze time at 2026-11-01 during import, move it to 2026-11-03, call the preprocessor: the system message says November 01 today and November 03 after the change.
The maintainers’ response
No response from the maintainers yet.
How this was made
The llm-call-audit skill read the code and wrote findings.json; nothing was run against the project’s providers. The full audit page is what leanprompt report --html writes from the same findings.
Corrections and takedown: email info@podwarden.com or open an issue.