load prompt from file in spec - #60
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Short Summary
Adds
PromptReftoSpecLoader, letting DAG task specs reference a prompt YAML file instead of an inline string. Thepromptfield in aTaskSpecnow accepts either"some text"(existing behavior, unchanged) or{ path: "./path/to/prompt.yaml" }. File loading is async-safe viaspawn_blocking, with basic path traversal rejection.Context
Previously,
TaskSpec.promptwas a plainString— always treated as an inline message. There was no way to point a workflow task at an existing prompt file, even thoughPrompt::from_pathalready supported loading.yaml/.jsonprompt definitions with full provider config, settings, and variable parameters.PromptRefdeserialization — a custom serdeVisitordispatches on value type: a YAML scalar becomesInline(String), a mapping with apathkey becomesFile(String). This is entirely backwards-compatible; no existing YAML spec needs to change.Before:
After (both forms valid):
Async safety —
Prompt::from_pathcallsstd::fs::read_to_stringsynchronously. Sincebuild_workflowisasync, wrapping intokio::task::spawn_blockingkeeps the blocking syscall off the runtime worker threads.Path safety — paths containing
..components are rejected at the loader level before any I/O. Full canonicalization/sandboxing is intentionally deferred;SpecLoaderis developer-facing and not exposed to untrusted user input.New error variant —
SpecError::PromptLoad { path, reason }distinguishes prompt file load failures from general workflow build errors.crates/potato_spec/src/spec.rsPromptRefenum with customDeserialize; changesTaskSpec.prompt: String→TaskSpec.prompt: PromptRef; adds 3 unit tests for deser branchescrates/potato_spec/src/loader.rsbuild_workflowbranches onPromptRef;Filearm usesspawn_blocking+..rejectioncrates/potato_spec/src/error.rsPromptLoad { path, reason }variantcrates/potato_spec/src/lib.rsPromptRefcrates/baked_potato/tests/agent/spec_test.rsSpecError::PromptLoad)crates/baked_potato/tests/agent/fixtures/prompt.yamlIs this a Breaking Change?
No. The
promptfield previously held aString; all existing YAML specs withprompt: "text"deserialize toPromptRef::Inline("text")and follow the same code path as before. The only public API addition isPromptRefitself andSpecError::PromptLoad.