Repository navigation
Let an agent class link to its usage documentation - #89
josephschorr wants to merge 1 commit into
Conversation
Add an optional spec.docs link to AgentClass. It appears as a Documentation button on the agent's Slack Home tab and is named in the agent's system prompt, so the agent can share it when asked how to use it. The link must be safe to follow as a plain GET: https, a DNS hostname, no query string and no credentials. The rule is enforced at admission and again wherever the value is read.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
samkim
left a comment
There was a problem hiding this comment.
This PR adds an optional spec.docs link to AgentClass. It shows as a Documentation button on the Slack Home tab and as a section in the runner's system prompt, and it is validated by one regex (CRD pattern and Go) plus a net/url parse. The core design holds up: the Go and CRD patterns are pinned together by a test, the Slack and runner readers drop and log a bad link, and both prompt-compose sites are wired.
Verdict: ready after the inline fixes, plus the ship-gate runs below.
Issues, highest impact first:
oap agent showprints the stored link without validating it, although the PR says every reader re-applies the rule (see inline). Minor: admission blocks bad values, so only a value stored by another route would be shown.- The workshop stand-in copies
Docsraw, so one bad stored value would fail the whole rehearsal projection where every other reader just drops the link (see inline). Nit, hypothetical today. - Ship gate: the PR says integration and e2e were not run. The CRD pattern is only exercised against a real apiserver in envtest, and
test/e2e/inprocess_runner_factory.gochanged. Runmage test:integrationandmage test:e2ebefore merge. - Testing: no bronzethread bundle covers the new prompt section, so dropping either
WithDocsURLcall (internal/cmd/runner/main.go:2147,test/e2e/inprocess_runner_factory.go:1810) keeps every suite green. The repo rule asks for a bundle for new user-visible behavior; consider one assertingsystemPromptContainsthe link.
Questions for the author:
- Admission relies on the CRD pattern alone. Is there an envtest case applying a bad link (http, IP host, query, userinfo, over 2048 chars) to a real apiserver, or is that deliberately left out?
- Dotted internal names (
x.svc.cluster.local,.internal) pass the rule. Intended? Nothing in this diff fetches the link server-side.
This review was drafted by an automated pipeline and checked before submission.
| fmt.Fprintf(out, "Namespace: %s\n", ac.Namespace) | ||
| fmt.Fprintf(out, "Description: %s\n", ac.Spec.Description) | ||
| if ac.Spec.Docs != "" { | ||
| fmt.Fprintf(out, "Docs: %s\n", ac.Spec.Docs) |
There was a problem hiding this comment.
[minor] oap agent show prints spec.docs without validating it
Problem: ac.Spec.Docs is written to the terminal raw. Every other reader (pkg/agent/runner/docslink.go:19, pkg/channels/channelkinds/slack/app_home.go:194) goes through AgentClassSpec.DocsURL() and drops and logs a failing value. A stored value that fails the rule (the case the read-side check exists for) would be printed as-is, including control or escape characters or a ?token= query. pkg/apis/v1alpha1/agentclass_docs.go says "Every reader calls this anyway", which is false here.
Fix: replace the ac.Spec.Docs != "" block with docs, err := ac.Spec.DocsURL(). If err != nil, print a visible line such as Docs: (invalid link omitted: <err>) (do not print the raw value). Else if docs != "", print Docs: <docs>.
Test: add cmd/oap/internal/agentcmd/show_test.go with a table (valid link printed, empty prints no Docs line, invalid value prints the omitted note and not the raw string). Model the fixture on inspect_test.go and use a fake client for g.Bundle() if one exists in cmd/oap/internal/aptest. Run go test ./cmd/oap/internal/agentcmd/ -run AgentShow.
Constraints: AGENTS.md "Never silently drop errors": surface a user-visible message when a CLI command omits something.
| Spec: spiceboxv1alpha1.AgentClassSpec{ | ||
| DisplayName: source.Spec.DisplayName, | ||
| Description: desc, | ||
| Docs: source.Spec.Docs, |
There was a problem hiding this comment.
[nit] Stand-in copies source.Spec.Docs without the read-side check
Problem: if the source class holds a value that fails the docs pattern, the stand-in Create (lines 811 and 904) is rejected by the CRD pattern and the whole rehearsal projection fails, whereas every other reader omits a bad link. This is hypothetical today, since the source passed the same pattern at admission.
Verify: confirm the source value can only enter via the CRD (no other store path). If so this is optional hardening.
Fix: in projectStandin, call docs, err := source.Spec.DocsURL(). On an error, log it with namespace and class and leave Docs empty. Update the doc comment above ("copied verbatim") accordingly.
Test: extend pkg/web/workshopprojectsrv/workshopprojectsrv_test.go with a source holding an invalid Docs and assert the stand-in has an empty Docs. Run go test ./pkg/web/workshopprojectsrv/.
What
An agent class can now carry an optional
spec.docslink to documentation on how to use the agent.oap agent showprints the link when one is set.Nothing changes for a class that does not set the field.
Link rules
The link has to be safe to follow as a plain GET:
httpsonlylocalhost), with an optional port#fragmentuser:password@portionA link that breaks these rules is rejected when the class is applied. The same rule is applied again wherever the link is read, and a link that fails there is left out and logged rather than shown.
Testing