max_tokens parameter, why it mattered in this case, and how to choose an appropriate value for your project.
Expose the Kubernetes cluster to the container (run locally in your terminal):
- The earlier truncation was caused by the LLM response being capped by the
max_tokensparameter passed to the agent call. - To fix this, open
structured_auditor.py, find the prompt definition and therun_agentcall, and increase themax_tokensvalue (examples below). - Always ensure the sum of prompt tokens and desired response tokens stays within your model’s maximum context size.
Choose
max_tokens based on the length of the expected output and your cost/latency trade-offs. If you need exhaustive, untruncated output, increase the limit; if you only need summaries, consider restructuring the prompt to produce shorter, structured outputs (e.g., JSON).- In this demo I doubled the output token budget from
2048to4096. Make sure the model you use supports that many tokens (prompt + output combined) or the request may be rejected or still truncated. - Edit the
run_agentcall instructured_auditor.pyto setmax_tokens=4096:
Setting a large
max_tokens increases cost and can impact latency. Also confirm your model’s maximum context length (prompt + completion) before raising this value. Consider structured outputs (JSON), streaming, or limiting scope as alternatives.max_tokens, save) and re-running the script, the audit output was no longer cut off and included the full resource-by-resource details and summary sections.
Excerpt of the improved audit output (as printed by the program):
- Fully Compliant Resources: 0
- Non-Compliant Resources: 27 (100%)
Tag Coverage Analysis
Critical Observations
- Slack-channel Tag: This tag is completely absent across all 27 resources (0% coverage). This is a critical gap for FinOps governance and operational alerting.
- System-Generated Resources: All
kube-root-ca.crtConfigMaps across namespaces lack any labels. These are system-generated resources but still appear in the audit scope. - Inventory Namespace Excellence: The inventory namespace demonstrates the highest compliance with 5 of 6 required tags present on most resources. Only the
slack-channeltag is missing. - Payment Namespace Inconsistency: The payment namespace shows inconsistent labeling patterns. Some resources have owner and environment tags while others lack application tags entirely.
- Default Namespace: The default namespace contains multiple untracked resources (analytics-collector, untracked-config, analytics-data) with minimal or no labels, suggesting these may be orphaned or legacy resources.
max_tokens further, consider these alternatives to reduce output length or avoid higher costs:
- Request machine-readable output (JSON) so the agent produces concise, parseable results.
- Stream results incrementally if supported by your LLM client.
- Limit audit scope (fewer namespaces or resource types) to reduce output size.
- Summarize results at higher level and request drilling only for problematic namespaces/resources.
max_tokens
For model-specific token/context limits and best practices, check your LLM provider’s documentation (for example, see the model token limits in your provider’s docs).
A future whiteboarding session will decide the audit output format (human-readable vs. structured) and discuss downstream automation for remediation and reporting.