Skip to content

Let an agent class link to its usage documentation - #89

Open
josephschorr wants to merge 1 commit into
mainfrom
agentclass-docs-link
Open

josephschorr wants to merge 1 commit into
mainfrom
agentclass-docs-link

Conversation

@josephschorr

Copy link
Copy Markdown
Member

What

An agent class can now carry an optional spec.docs link to documentation on how to use the agent.

  • Slack Home tab: the link appears as a "Documentation" button under the agent's description.
  • Agent prompt: the agent is told where its documentation lives, so it can share the link when someone asks how to use it.
  • CLI: oap agent show prints 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:

  • https only
  • a DNS hostname (no IP addresses, no bare names such as localhost), with an optional port
  • an optional path and #fragment
  • no query string
  • no user:password@ portion
  • plain URL characters only; anything else must be percent-encoded

A 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

  • Unit suite passes.
  • Integration and e2e suites have not been run on this branch yet.

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.
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openagentprimitives Ready Ready Preview Dec 2, 2026 8:29pm UTC

Request Review

@samkim samkim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. oap agent show prints 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.
  2. The workshop stand-in copies Docs raw, so one bad stored value would fail the whole rehearsal projection where every other reader just drops the link (see inline). Nit, hypothetical today.
  3. 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.go changed. Run mage test:integration and mage test:e2e before merge.
  4. Testing: no bronzethread bundle covers the new prompt section, so dropping either WithDocsURL call (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 asserting systemPromptContains the link.

Questions for the author:

  1. 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?
  2. 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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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/.

This branch was successfully deployed

1 active deployment
Preview — 0097f28d Deployed Dec 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants