Skip to content

feat(coding-agent): add afm-core Darwin tiny title engine - #9683

Open
audreyt wants to merge 47 commits into
can1357:mainfrom
audreyt:feat/tiny-afm-core
Open

audreyt wants to merge 47 commits into
can1357:mainfrom
audreyt:feat/tiny-afm-core

Conversation

@audreyt

@audreyt audreyt commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What

Add afm-core as an opt-in Darwin engine for session titles (providers.tinyModel) and unexpected-stop classification (providers.unexpectedStopModel). On Darwin it talks to Apple SystemLanguageModel.default through a small Swift sidecar (bundled for Apple Silicon; compiled on first use on other Darwin triples). omp tiny-models download afm-core probes Apple Intelligence readiness; it does not fetch Hugging Face / ONNX weights.

This is not a catalog provider. The key lives on the shared memory-model registry so unexpected-stop (and therefore providers.memoryModel / providers.autoThinkingModel) can call the same sidecar complete(). Defaults stay online. The OS serves AFM 3 Core Advanced when the Mac has it.

Why

Session titles and short classify jobs are offline-friendly. On a Mac that already has Apple Intelligence, there is no reason to download another 200–700 MB ONNX model just to name the session or classify a stop. Fail closed when the OS is not Darwin, Apple Intelligence is off, or the model reports modelNotReady.

Testing

  • bun test test/tiny-apple-fm.test.ts test/tiny-models-cli.test.ts test/tiny-title-generator.test.ts
  • biome check on the touched TypeScript files
  • Live sidecar: status → AFM 3 Core Advanced, context 8192. Title / auto-thinking / unexpected-stop classifier prompts returned parseable one-line answers well under the 4s abort.

  • bun check passes (biome on touched files; focused tests above)
  • Tested locally
  • CHANGELOG updated (if user-facing)

Copilot AI lite review requested due to automatic review settings August 25, 2026 02:26

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@roboomp roboomp added agent Agent runtime planning and orchestration cli CLI commands and arguments feat review:p2 triaged labels Aug 25, 2026

@roboomp roboomp left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @audreyt — clean, well-scoped feature. P2: opt-in only, defaults unchanged (title default stays online/lfm2-700m), fails closed off-Darwin/when Apple Intelligence is off, changelog present, and the added tests exercise real observable contracts (probe/complete via env-override sidecar, worker title path avoids transformers, download-as-probe). It ranks P2 rather than P1 only because it introduces a new native compile-on-first-use mechanism (xcrun swiftc) that is a maintainer-policy call, not because anything is broken.

Findings (both non-blocking):

  • should-fix apple-fm.ts:44: process.arch (x64) is fed into a Swift target triple that expects x86_64; malformed triple on Intel hosts. Practically moot since AFM is Apple-silicon only.
  • nit apple-fm.ts:45: TextDecoder over result.stderr and node:fs sync APIs vs the Bun-first convention.

Open question for the maintainer: afm-core is offered in the tiny-model picker/TINY_TITLE_MODEL_OPTIONS on every platform; off-Darwin it degrades gracefully (worker throws -> local title returns null -> online fallback), so no hard break, but you may want it hidden from non-Darwin selection.

Comment thread packages/coding-agent/src/tiny/apple-fm.ts Outdated
Comment thread packages/coding-agent/src/tiny/apple-fm.ts Outdated

@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: b55d990bcb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/coding-agent/src/tiny/models.ts
Comment thread packages/coding-agent/src/tiny/worker.ts Outdated
@audreyt
audreyt force-pushed the feat/tiny-afm-core branch from b55d990 to 7fc5ced Compare August 25, 2026 02:41

@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: 7fc5ced4d7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/coding-agent/src/tiny/worker.ts Outdated
@audreyt

audreyt commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Lint/typecheck should be green on the next run (check:types is clean at HEAD). Adding src/tiny/apple-fm.ts was enough to tip a pre-existing unannotated Map in eval-code-mode-declarations.test.ts (the sibling test already had explicit type args).

The remaining red jobs (Test TS native/integration, Test coding-agent native/unit) are new DiffStream / rasterizeSvg is not a function. PR CI loads @oh-my-pi/pi-natives-linux-x64@latest from npm rather than building this tree (ci.yml native_addons PR path). origin/main at 969a94c is green because it bazel-builds current natives. This PR does not touch crates/ or packages/natives.

@audreyt
audreyt force-pushed the feat/tiny-afm-core branch from 7fc5ced to d011bcf Compare August 25, 2026 02:53

@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: d011bcf104

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/coding-agent/src/tiny/apple-fm.ts Outdated
@audreyt
audreyt force-pushed the feat/tiny-afm-core branch from d011bcf to ee33367 Compare August 25, 2026 03:14

@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: ee333679b0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/coding-agent/src/tiny/apple-fm.ts Outdated
Comment thread packages/coding-agent/src/tiny/apple-fm.ts Outdated
@audreyt
audreyt force-pushed the feat/tiny-afm-core branch from ee33367 to 0905f8d Compare August 25, 2026 03:19

@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: 0905f8d967

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/coding-agent/src/tiny/apple-fm.ts Outdated
@audreyt
audreyt force-pushed the feat/tiny-afm-core branch from 0905f8d to 95eabc4 Compare August 25, 2026 03:26

@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: 95eabc423c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/coding-agent/src/tiny/apple-fm.ts Outdated
Comment thread packages/coding-agent/test/tiny-apple-fm.test.ts Outdated
@audreyt
audreyt force-pushed the feat/tiny-afm-core branch 2 times, most recently from 5a7125c to fa6add4 Compare August 25, 2026 03:43

@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: fa6add4edb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/coding-agent/src/tiny/apple-fm.ts Outdated
@audreyt
audreyt force-pushed the feat/tiny-afm-core branch from fa6add4 to 8201c63 Compare August 25, 2026 04:03

@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: e4001e636a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/coding-agent/src/tiny/apple-fm.ts
Comment thread packages/coding-agent/src/tiny/worker.ts Outdated
Comment thread packages/coding-agent/src/tiny/models.ts Outdated

@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: 28dc0cc799

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/coding-agent/package.json Outdated

@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: 816655187c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/coding-agent/src/tiny/worker.ts Outdated

@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: da779eb84a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/coding-agent/src/tiny/apple-fm.ts Outdated
Comment thread packages/coding-agent/src/tiny/worker.ts Outdated

@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: 457305ed24

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/coding-agent/src/tiny/worker.ts Outdated
Comment thread packages/coding-agent/test/tiny-apple-fm.test.ts Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

Remove the static TINY_TITLE_LOCAL_MODELS field restatement. Temp
sidecars are created with Bun.write and fs.promises so the suite
does not block the test event loop on sync I/O.
After a terminal availability failure, later generate() calls return
immediately. Emit status error so title-progress listeners unsubscribe
instead of leaking a UI closure per turn.
A sibling omp holding the first-use sidecar lock can exhaust withFileLock
retries. That error is not an availability verdict, so the next title
must still be allowed to run.
The unlocked existence check could pair a newly renamed binary with a
previous identity stamp. Recheck bin+stamp only after acquiring the lock,
reusing the same Bun.file handles.
withFileLock's acquire message is owned by pi-utils. Translate it at the
sidecar boundary and classify apple_fm_busy as request-scoped so the
title client does not depend on another package's wording.
AFM matched the acquire failure by message text, so a wording change in
pi-utils would silently reclassify a busy install as a terminal
availability failure. Throw LockAcquireError and match it by type.
Document generation-error recovery and cancellable lock waits.
Content-identical refresh after upstream denied fork CI reruns.
…ased sections

Move the withFileLock entries from released 18.1.19 to Unreleased and drop merge-artifact additions to released sections.
afm-core is accepted for providers.memoryModel, autoThinkingModel, and unexpectedStopModel and routes through the shared on-device worker; it was only ever unscored on the memory extract set, not title-only.
- Reset both CHANGELOGs to upstream released sections; keep afm-core and
  file-lock entries under Unreleased (replayed changelog commits had
  embedded them in 18.2.5/18.1.11 and duplicated them).
- Restore the AFM prewarm early-return dropped with the duplicate
  fork-side picks.
- Restore afm-core in the providers.tinyModel settings enum.
- Restore the title-generate test's status-probe fixture and progress
  assertions plus the merge test order.
- Restore merge import order and mlxRepo doc wording.
- worker AFM chat: run the readiness probe inside the request scope so
  transient probe failures (modelNotReady, unclassified transport)
  resolve empty and later completions re-probe, instead of failing the
  worker and poisoning later titles/completions. Load still throws.
- title client: route Foundation Models workers past the MLX launch
  branch so the missing-mlxRepo throw cannot trip module-wide
  mlxUnavailable for real MLX models.
- file-lock: reuse sleepLong for abortable retry sleeps instead of a
  local setTimeout helper that overflows past the 32-bit timer ceiling.
- tests: worker-path probe recovery and MLX-availability preservation.
# Conflicts:
#	docs/local-models.md
#	docs/settings.md
#	packages/coding-agent/package.json
#	packages/coding-agent/src/tiny/models.ts
#	packages/coding-agent/src/tiny/title-client.ts
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

audreyt and others added 2 commits September 22, 2026 13:24
The 2026-09-21 merge of origin/main adopted upstream's renamed
isTinyLocalModelKey/getTinyLocalModelSpec and in doing so dropped the
skipped-model branch from 095c8ff. generate() returned null for a
failed model without emitting status error, so title-progress listeners
leaked again and tiny-apple-fm "disables AFM after a terminal failure"
failed. Reinstate the branch on the renamed helpers.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

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

Labels

agent Agent runtime planning and orchestration cli CLI commands and arguments feat review:p2 triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants