Skip to content

feat: codemode-decision package, decision.ask across OpenAI and TypeSafe (SHFT-2968) - #105

Merged
Michaelliv merged 2 commits into
mainfrom
feat/SHFT-2968-decision-package
Nov 23, 2026
Merged

Michaelliv merged 2 commits into
mainfrom
feat/SHFT-2968-decision-package

Conversation

@Michaelliv

Copy link
Copy Markdown
Collaborator

Adds @shiftlabs/codemode-decision: one plugin, decision, that asks a decision model questions through the provider the connection chooses.

Action

decision.ask({ input?, images?, questions }) → { provider, model, inputTokens?, answers }, with answers keyed by question name.

  • Question types: yesNo, choice (2 to 255 options), score (2 to 10 levels); up to 400 questions a call.
  • Answers have one shape from both providers: yesNo gives probability; choice and score give the answer, confidence and every option's or level's probability. A declined question is { type: "refusal" }.
  • input is text or a JSON object. images are local PNG or JPEG paths, identified by their bytes.

Design

  • The connection resolves the provider (provider, else the first with a key: openai, then typesafe) and the model. The action has no input for either, and there is no models action.
  • Provider-only features are left out: TypeSafe box and long context, OpenAI conversation and tool-call input, images inside one question.
  • The bundled typesafe plugin stays.
  • A provider is data plus two functions, and a host adds its own with decision([mine, ...PROVIDERS]).

Also in this PR, in codemode core

  • credentials/router.ts: routerCredential, routerConnectionFields, namedProvider, keyedProviders. websearch, imagegen and decision use them in place of three copies. Documented as a recipe in docs/credentials.md.
  • utils/image.ts: imageFacts, readLocalImage, imageDataUrl, imageBase64, IMAGE_EXTENSIONS, moved from imagegen so decision can use them.
  • actions.describe shows the shape of a keyed object's values (values), so questions is discoverable.

websearch and imagegen change only by that refactor.

Not proven

No question has been asked with a working key. Request and answer shapes come from OpenAI's Decisions guide and reference and TypeSafe's System One reference, with stubbed hosts in tests. Both endpoints answer 401 to a made-up key.

  • confidence is each provider's own figure and is not comparable across providers.
  • TypeSafe calls its image input not yet ready for production; a request with images sends its opt-in header.
  • Score levels go to TypeSafe as label: description text.

Tests

19 in the package; 2,748 in codemode; all repository gates pass.

@Michaelliv
Michaelliv merged commit 9bbe1ff into main Nov 23, 2026
1 check passed
@Michaelliv
Michaelliv deleted the feat/SHFT-2968-decision-package branch November 23, 2026 15:27
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.

1 participant