Make Kubernetes log tools gather the right evidence for agents#10
Open
rshdhere wants to merge 2 commits into
Open
Make Kubernetes log tools gather the right evidence for agents#10rshdhere wants to merge 2 commits into
rshdhere wants to merge 2 commits into
Conversation
…ents Agents debugging a k8s deployment had to guess pod names, remember --previous for CrashLoopBackOff, and fetch Warning events separately. Structured target/selector/namespace fields now resolve pods, fan out logs (auto --previous on restarts), include events, and compact once. Legacy args passthrough to kubectl logs remains for power users.
Visual before/after for reviewers: raw Kubernetes log token cost versus Codag compact output, plus the structured multi-pod fetch path.
Author
|
focus on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this solve?
AI agents debugging Kubernetes usually have to invent a workflow: find the deployment’s pods, pull logs, remember
--previousfor crash loops, check Warning events, then paste a huge raw dump into context.Codag already compresses logs. This PR makes
tail_kubernetesbetter at gathering the right evidence first, then compacting once.What changed
Agents can call structured fields instead of only raw
kubectl logsargs:{ "target": "deployment/prod-api", "namespace": "prod", "since": "1h" }That path:
--all-containers)--previouswhenrestartCount > 0(or whenprevious=true)[pod=…],[event]) and sends one compact requestLegacy
args=[...]passthrough is unchanged.Demo honesty (please read)
Token figures use Codag’s existing estimator: characters ÷ 4 (
internal/passthrough.EstTokens). They are not tiktoken / model-exact counts.What is real
argocd/argocd-repo-server,kubectl logs --since=6h.codag wrap --quiet --deterministicagainst a slice of those logs (hosted free/deterministic compact path — not invented in this PR).What was misleading before (corrected)
An earlier draft compared full 6h raw (~314k est. tokens) to compact output from only the first 800 lines. That is not the same window.
Same-window measurement (800-line slice of the 6h dump):
codag wrap --deterministicFull 6h raw is still large (~314k est. tokens); that number is only “how big the unfiltered stream is,” not the compact baseline.
What this PR did not prove in the screenshots
target=deployment/...) hitconnection reset by peeragainst the hosted compact API on the full gather, so the AFTER image iscodag wrap, not a successful end-to-endtail_kubernetesstructured tool result on that cluster.Images
The side-by-side image still mentions the older framing; treat the table above as the source of truth for numbers.
Why this belongs here
Fits
codag-cli: MCP + provider log gathering for agents, reusing the existing compact API. No new hosted product surface.Happy to delete
docs/tail-kubernetes-demo/before merge if you want a code-only diff.Test plan
go test ./...codag wrap --deterministicon an 800-line windowtail_kubernetesagainst your API/clusterargs=[pod…]still works