Skip to content

Add agent index discovery endpoint#403

Merged
zz-plant merged 1 commit into
mainfrom
codex/evaluate-implementing-graphql-api
Jan 15, 2026
Merged

Add agent index discovery endpoint#403
zz-plant merged 1 commit into
mainfrom
codex/evaluate-implementing-graphql-api

Conversation

@zz-plant

Copy link
Copy Markdown
Owner

Motivation

  • Provide a lightweight discovery index for agent tooling that centralizes endpoints, docs links, and quick-start recommendations.
  • Surface a single agent-focused entry that can be versioned alongside other API snapshots for reproducible tooling and citations.

Description

  • Add a new buildEndpointMap helper and createAgentIndexResponse in src/utils/api-responses.ts that assemble discovery metadata, a recommended quick-start list, and a full endpoint mapping.
  • Include agent-index.json and research.json in the API endpoint lists and update buildEndpoints to emit the expanded set of exports.
  • Add runtime routes src/pages/api/agent-index.json.ts and src/pages/api/v/2026.01/agent-index.json.ts that expose the current and versioned agent index.
  • Update the API reference page src/pages/api/index.astro and docs docs/agent-metadata.md to document the new �/api/agent-index.json endpoint.

Testing

  • Ran bun run check, which runs Lint, Unit Tests, Typecheck, Astro Check, Validate JSON, and Validate Glossary, and all checks passed.

Codex Task

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jan 15, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
et3 30fac45 Commit Preview URL

Branch Preview URL
Jan 15 2026, 06:10 AM

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @zz-plant, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the API's discoverability for agent-based systems by introducing a dedicated, centralized index. This new endpoint aims to streamline how agents locate and interact with various API services, providing a consistent and versionable entry point for tooling. The changes facilitate better integration and reproducibility for automated clients by offering a structured overview of available resources and recommended starting points.

Highlights

  • New Agent Index Endpoint: Introduced a new API endpoint, /api/agent-index.json, designed to serve as a lightweight, centralized discovery index for agent tooling. This endpoint provides a single entry point for agents to find other API endpoints, documentation links, and quick-start recommendations.
  • API Response Utilities: Added a new helper function buildEndpointMap to programmatically generate a comprehensive map of all API endpoints. A new createAgentIndexResponse function was also implemented to construct the detailed JSON response for the agent index, including metadata, discovery links, and recommended quick-start resources.
  • Documentation and Versioning: The new agent index endpoint is documented in docs/agent-metadata.md and listed on the API reference page (src/pages/api/index.astro). A versioned route for the agent index (/api/v/2026.01/agent-index.json) has also been added to support future API versioning.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@zz-plant zz-plant merged commit 4b7306d into main Jan 15, 2026
1 of 2 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 30fac452a2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

findings: `${normalizedBase}/findings.json`,
diagnosticResults: `${normalizedBase}/diagnostic-results.json`,
ragCorpus: `${normalizedBase}/rag-corpus.jsonl`,
research: `${normalizedBase}/research.json`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid advertising non-existent versioned research endpoint

The new research entry is built by concatenating basePath for every index. The versioned agent/site index routes pass basePath: "/api/v/2026.01", but there is no src/pages/api/v/2026.01/research.json.ts, so /api/v/2026.01/research.json will 404 and any consumer following the discovery metadata will break. Consider either adding the versioned research endpoint or mapping research to the unversioned /api/research.json when generating versioned indexes.

Useful? React with 👍 / 👎.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new agent index discovery endpoint, which is a great addition for improving the discoverability of the API for tooling. The implementation is clean and follows a good structure by creating new API routes in Astro and centralizing the response creation logic in src/utils/api-responses.ts.

The new buildEndpointMap helper is a good step towards better organization. My review includes a few suggestions to further improve maintainability by reducing code duplication and eliminating magic strings/numbers. Specifically, I've pointed out opportunities to:

  • Create a single source of truth for the endpoint definitions to be shared between buildEndpointMap and buildEndpoints.
  • Extract hardcoded paths and numbers into named constants for better readability and easier updates.

Overall, this is a solid contribution that enhances the API. Addressing the feedback will make the new code even more robust and easier to maintain.

Comment on lines +32 to +59
const buildEndpointMap = (
basePath: string,
options?: { includeReleaseEndpoints?: boolean },
) => {
const normalizedBase = basePath.replace(/\/$/, "");

return {
agentIndex: `${normalizedBase}/agent-index.json`,
siteIndex: `${normalizedBase}/site-index.json`,
standards: `${normalizedBase}/standards.json`,
clauses: `${normalizedBase}/clauses.json`,
mechanisms: `${normalizedBase}/mechanisms.json`,
validators: `${normalizedBase}/validators.json`,
glossary: `${normalizedBase}/glossary.json`,
antiPatterns: `${normalizedBase}/anti-patterns.json`,
evidencePacks: `${normalizedBase}/evidence-packs.json`,
findings: `${normalizedBase}/findings.json`,
diagnosticResults: `${normalizedBase}/diagnostic-results.json`,
ragCorpus: `${normalizedBase}/rag-corpus.jsonl`,
research: `${normalizedBase}/research.json`,
...(options?.includeReleaseEndpoints
? {
releases: `${normalizedBase}/releases.json`,
changelog: `${normalizedBase}/changelog.json`,
}
: {}),
};
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This new buildEndpointMap function is a good abstraction. However, it introduces duplication with the buildEndpoints function, as both now maintain separate but similar lists of endpoints. This could lead to maintenance issues, such as forgetting to update one list when an endpoint is added or changed.

To create a single source of truth, you could define the endpoint information in a shared data structure. This would improve maintainability and reduce the risk of inconsistencies.

Here's an example of how you could refactor this:

// Define endpoints in a single place
const ENDPOINTS = {
  core: {
    agentIndex: 'agent-index.json',
    siteIndex: 'site-index.json',
    standards: 'standards.json',
    clauses: 'clauses.json',
    mechanisms: 'mechanisms.json',
    validators: 'validators.json',
    glossary: 'glossary.json',
    antiPatterns: 'anti-patterns.json',
    evidencePacks: 'evidence-packs.json',
    findings: 'findings.json',
    diagnosticResults: 'diagnostic-results.json',
    ragCorpus: 'rag-corpus.jsonl',
    research: 'research.json',
  },
  release: {
    releases: 'releases.json',
    changelog: 'changelog.json',
  },
};

// Refactored buildEndpointMap
const buildEndpointMap = (
  basePath: string,
  options?: { includeReleaseEndpoints?: boolean },
) => {
  const normalizedBase = basePath.replace(/\/$/, '');
  const files = { ...ENDPOINTS.core };
  if (options?.includeReleaseEndpoints) {
    Object.assign(files, ENDPOINTS.release);
  }

  return Object.fromEntries(
    Object.entries(files).map(([key, file]) => [key, `${normalizedBase}/${file}`])
  ) as Record<keyof typeof ENDPOINTS.core & keyof typeof ENDPOINTS.release, string>;
};

// Refactored buildEndpoints
const buildEndpoints = (
  basePath: string,
  options?: { includeReleaseEndpoints?: boolean },
) => {
  const normalizedBase = basePath.replace(/\/$/, '');
  let files = Object.values(ENDPOINTS.core);
  if (options?.includeReleaseEndpoints) {
    files.push(...Object.values(ENDPOINTS.release));
  }
  return files.map((endpoint) => `${normalizedBase}/${endpoint}`);
};

This approach would also make the quickStart list in createAgentIndexResponse more robust, as you could define it based on the keys of the ENDPOINTS object, preventing runtime errors from typos.

Comment on lines +135 to +143
discovery: {
sitemap: "/sitemap.xml",
robots: "/robots.txt",
},
docs: {
apiReference: "/api",
agentObjectModel: "/agents/spec",
agentObjectSchema: "/agents/spec.json",
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The hardcoded paths for discovery and docs are magic strings. It would be beneficial to define these as constants at a higher scope. This improves maintainability and ensures consistency if these paths are used elsewhere.

For example:

const DISCOVERY_PATHS = {
  SITEMAP: '/sitemap.xml',
  ROBOTS: '/robots.txt',
};

const DOCS_PATHS = {
  API_REFERENCE: '/api',
  AGENT_OBJECT_MODEL: '/agents/spec',
  AGENT_OBJECT_SCHEMA: '/agents/spec.json',
};

endpointMap.glossary,
endpointMap.research,
],
ragCorpusPreview: `${endpointMap.ragCorpus}?limit=200`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The limit 200 is a magic number. It would be better to define it as a named constant (e.g., RAG_CORPUS_PREVIEW_LIMIT) at a suitable scope for improved readability and maintainability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant