Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions packages/runner/src/builtins/llm-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,23 @@ function normalizeInputSchema(schemaLike: unknown): JSONSchema {
function getCellSchema(
cell: Cell<unknown>,
): JSONSchema | undefined {
return cell.schema ??
// If cell has a source cell, any resultRef has a schema attached
cell.getSourceCell<{ resultRef: Cell<unknown> }>({
type: "object",
properties: { resultRef: { asCell: true } },
})?.get()?.resultRef?.schema ??
// Otherwise, derive a simple object schema from the current value
buildMinimalSchemaFromValue(cell);
if (cell.schema) return cell.schema;

const sourceCell = cell.getSourceCell<{ resultRef: Cell<unknown> }>({
type: "object",
properties: { resultRef: { asCell: true } },
});
const sourceCellSchema = sourceCell?.key("resultRef").get()?.schema;
if (sourceCellSchema !== undefined) {
const cfc = new ContextualFlowControl();
return cfc.schemaAtPath(
sourceCellSchema,
cell.getAsNormalizedFullLink().path,
cell.schema,
);
}

return buildMinimalSchemaFromValue(cell);
}

function buildMinimalSchemaFromValue(charm: Cell<any>): JSONSchema | undefined {
Expand Down
2 changes: 1 addition & 1 deletion packages/runner/src/cfc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ export class ContextualFlowControl {
*/
schemaAtPath(
schema: JSONSchema,
path: string[],
path: readonly string[],
rootSchema?: JSONSchema,
extraClassifications?: Set<string>,
): JSONSchema {
Expand Down