Skip to content

Pro 9879 ai reference - #567

Open
BoDonkey wants to merge 3 commits into
mainfrom
pro-9879-ai-reference
Open

Pro 9879 ai reference#567
BoDonkey wants to merge 3 commits into
mainfrom
pro-9879-ai-reference

Conversation

@BoDonkey

@BoDonkey BoDonkey commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Please indicate which branch this PR should merge into:

Check one

  • main
  • latest
  • stable
  • Check if this PR will be resubmitted against another branch

Summary

Summarize the changes briefly, including which issue/ticket this resolves. If it closes an existing Github issue, include "Closes #[issue number]"
This PR adds the ai-adapter reference modules to the site. Closes pro-9879.

What are the specific steps to test this change?

For example:

  1. Run the website and log in as an admin
  2. Open a piece manager modal and select several pieces
  3. Click the "Archive" button on the top left of the manager and confirm that it should proceed
  4. Check that all pieces have been archived properly

What kind of change does this PR introduce?

(Check at least one)

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Build-related changes
  • Other

Make sure the PR fulfills these requirements:

  • It includes a) the existing issue ID being resolved, b) a convincing reason for adding this feature, or c) a clear description of the bug it resolves
  • The changelog is updated
  • Related documentation has been updated
  • Related tests have been updated

If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.

Other information:

@BoDonkey
BoDonkey requested a review from myovchev September 8, 2026 19:10
@linear

linear Bot commented Sep 8, 2026

Copy link
Copy Markdown

PRO-9879

|---|---|---|
| `low` | `gemini-3.1-flash-lite` | — |
| `medium` | `gemini-3.5-flash` | — |
| `high` | `gemini-3.5-flash` | `high` |

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.

I now realize we don't use Gemini Pro. But I guess is OK as a start. I didn't spent too much time on Gemini.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There isn't a Pro text encoder. I also noticed that 3.5 is a little stale. There is a 3.5-flash-lite now also.


**For OpenAI proper, prefer `openai`.** It speaks OpenAI's first-class Responses API and supports `reasoning` alongside `tools`.

[`openai-compatible`](/reference/modules/ai-adapter-openai-compatible.md) speaks Chat Completions, the de facto wire standard of the whole ecosystem — that is what makes it the universal adapter. It works against `api.openai.com` too, but there a `tools` request drops `reasoning`, because the service rejects the combination in that dialect. Aliased entries describe other services, which accept it, and pass through untouched.

@myovchev myovchev Sep 9, 2026

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.

but there a toolsrequest dropsreasoning`` - this sounds odd, do we need the there part?

@BoDonkey BoDonkey Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Clarified and language cleaned up.

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

This was a long read (!) but I think overall is very clear and helpful. I spotted some minor problems. Some of my comments are only "thinking loud" stuff.

Comment thread docs/reference/modules/ai.md Outdated
}
}
},
'my-module': {}

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.

Avoid using my-xxx, this is reserved apostrophe thing and can behave in unexpected ways.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment thread docs/reference/modules/ai.md Outdated
| `pending` | `'refuse'` \| `'execute'` | What to do with a transcript ending in unanswered tool calls. See [Suspension](#suspension-asking-the-user-mid-run). |
| `toolInput` | object | Answers for suspended tool calls, keyed by tool call id. Requires `pending: 'execute'`. |
| `schema` | object | JSON Schema (object root) for structured output. |
| `effort` | string | The routing level to resolve. Defaults to `effort.default`. |

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.

Defaults to the value of `effort.default`

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

{ type: 'image', image: { url: 'https://example.com/photo.jpg' } }
]
}
]

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.

Here the dev should also see the assistant entry (between the user queries), leaving them out is confusing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Improved.

Comment thread docs/reference/modules/ai.md Outdated
| text | `{ type: 'text', text }` | `user`, `assistant` |
| image | `{ type: 'image', image: { url } }` or `{ type: 'image', image: { data, mediaType } }` | `user`, `assistant` |
| tool call | `{ type: 'toolCall', id, name, input }` | `assistant` |
| tool result | `{ type: 'toolResult', toolCallId, output }` or `{ …, error }` | `tool` |

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.

The table explains entries that are NOT in the example above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated and clarified.

Comment thread docs/reference/modules/ai.md Outdated
// }
```

`active` answers "is AI usable"; `modelCatalog` answers "what is configured". Under mock mode with no providers, `active` is `true` and the catalog is empty.

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.

We have (probably forgot to document it) apos.ai.mockMode boolean as well, so it's possible to check that too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

apos.ai.mockmode is documented, but worth adding here. (see lines 523 and 1539)

Comment thread docs/reference/modules/ai.md Outdated

### `can(req, action, docOrType, [mode])`

The AI permission seam. Same signature and semantics as `apos.permission.can` — see [Permissions and workflow](/guide/permissions-and-workflow.md) — but it is **not** a plain proxy: it applies AI-specific policy first, and can only ever be as restrictive as `apos.permission.can`, never looser.

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.

Meant to be used with tools or anything AI executed on behalf of the current user - probably worth mentioning.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Clarified and updated.

Comment thread docs/reference/modules/ai.md Outdated

## Tools

Tools are how a model does things: read content, search, write a draft, publish. The engine owns the loop; you own the handlers.

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.

Do not mention publish here - it's not clear the approach we take in the future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed here and several other places.


`input` is a JSON Schema describing the arguments the model may pass. This tool takes none, so `{ type: 'object' }` — an object with nothing in it — is the whole schema. The handler returns an object, and that object is what the model reads.

`kind: 'query'` says the tool only reads. Queries the model asks for together run in parallel; without it a tool defaults to `'action'` and runs serially, one after another. Tag your read-only tools and a model that asks for six of them at once gets its answer in the time of the slowest, not the sum. See [Kinds and scheduling](#kinds-and-scheduling).

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.

We never state what is the return type requirements - it's has to be ALWAYS an object, even when no schema is configured.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was clearly stated elsewhere, but it is also needed here.


// Instead of an inline function: a method on any module, resolved at
// startup. Handy when the handler is long or already exists
handler: 'page-tools:findPages'

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.

I'm not sure we should encourage anon functions as handlers. I'd say remove the last sentence. It depends on projects standards and architecture design raised by the dev providing the tools.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed.

Comment thread docs/reference/modules/ai.md Outdated

### Errors in handlers

There are exactly two outcomes for a failure, and the error code alone decides which.

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.

There are 3 - aiInput, described above in the "Suspend" details. It even got an AI tool throw example that showcases how it works.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@BoDonkey
BoDonkey requested a review from myovchev September 9, 2026 14:34
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