Skip to content

Runtime: compose typed hosted external-context tools - #386

Merged
roackb2 merged 1 commit into
mainfrom
codex/external-context-composition
Sep 7, 2026
Merged

roackb2 merged 1 commit into
mainfrom
codex/external-context-composition

Conversation

@roackb2

@roackb2 roackb2 commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Outcome

Hosted adopters can now compose an exact run-scoped tool surface from Heddle's
built-in external-context tools without copying schemas, resolving provider
credentials twice, or materializing authorized image content as a temporary
file.

Closes #384.

Public contract

  • ToolDefinition<Input, Output> / ToolResult<Output> retain typed schema and
    result information while tool execution still validates raw unknown input.
  • WebSearchInputSchema, WebSearchOutputSchema,
    ViewImageInputSchema, ViewImageOutputSchema, and their inferred types are
    exported from @heddleagent/runtime/advanced.
  • RunAgentLoopOptions.toolkits constructs host toolkits after provider
    resolution and works with includeDefaultTools: false.
  • stored OAuth is acquired once as an access-token-only request credential for
    Heddle-created runs/request-scoped toolkits; credentialStorePath can be
    independent from runtime state.
  • view_image accepts generic opaque reference / references through a host
    resourceResolver, with bounded streaming reads, supported-media checks,
    cancellation, optional byte-count/SHA-256 verification, and no temp file.
    Existing local paths remain supported.
  • provider-backed web/image requests now receive the tool cancellation signal.

Product authorization, object lookup/availability, provenance persistence,
database transactions, and job policy remain adopter-owned.

Verification

  • yarn typecheck
  • yarn lint
  • focused contracts/runtime/tools: 3 files, 127 tests passed
  • unit suite: 145 files, 957 tests passed
  • integration suite excluding the environment-sensitive global-skill catalog
    case: 48 files, 425 tests passed
  • request-scoped heartbeat credential test: 5 tests passed
  • yarn build

The unfiltered local integration run has one unrelated environment-dependent
failure because /Users/roackb2/.agents/skills/orchestration/SKILL.md currently
exceeds Heddle's 1,024-character skill-description limit. No skill discovery
code is changed here; clean-environment CI remains the authoritative full-suite
check.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-07T09:21:08.142157Z f54e795 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

ℹ️ 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".

Comment on lines +220 to +223
return LlmProviderRuntimeService.resolve({
...input,
credential,
});

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 Remove the ignored API key before resolving the OAuth token

When a caller supplies a provider-tagged API key (for example, apiKeyProvider: 'openai') while stored OAuth is available and preferApiKey is false, the initial resolution correctly selects OAuth, but this second resolution passes both the original apiKey and the newly acquired credential. RuntimeCredentialService.assertRuntimeCredential rejects that combination, so a previously valid run now fails with “Provide either apiKey or credential” instead of honoring OAuth precedence.

Useful? React with 👍 / 👎.

Comment on lines +209 to +214
const credential = await RuntimeCredentialService.acquireRequestScopedCredentialForModel(
input.model,
{
storePath: input.credentialStorePath,
...(signal ? { signal } : {}),
},

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 Preserve interrupted results during credential acquisition

For a stored-OAuth run, aborting before or during request-credential acquisition makes throwIfAborted() reject through this awaited call, so AgentLoopRuntimeService.run() throws without producing its normal outcome: 'interrupted' result or terminal loop event. This differs from cancellation after acquisition, which is normalized by AgentRunService; handle the abort at this preflight boundary so callers retain one cancellation contract.

Useful? React with 👍 / 👎.

};
});

return await Promise.all([...pathFiles, ...referenceFiles]);

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 Cancel sibling image streams when one input fails

When a call contains multiple opaque references and one resolver or stream rejects, Promise.all returns immediately but does not cancel the other already-started reads. Since those reads only observe the external tool signal—and the tool timeout is cleared once the failed call returns—a slow or unbounded sibling stream can continue consuming host I/O and memory after tool completion; use an internal abort signal for the batch or read the bounded resources sequentially.

Useful? React with 👍 / 👎.

@roackb2
roackb2 merged commit ac3aa6d into main Sep 7, 2026
6 checks passed
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.

Expose typed request-scoped external-context tool composition

1 participant