refactor(session): yield instance context in system prompt (#25207)
This commit is contained in:
@@ -1443,7 +1443,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
|
|||||||
|
|
||||||
const [skills, env, instructions, modelMsgs] = yield* Effect.all([
|
const [skills, env, instructions, modelMsgs] = yield* Effect.all([
|
||||||
sys.skills(agent),
|
sys.skills(agent),
|
||||||
Effect.sync(() => sys.environment(model)),
|
sys.environment(model),
|
||||||
instruction.system().pipe(Effect.orDie),
|
instruction.system().pipe(Effect.orDie),
|
||||||
MessageV2.toModelMessagesEffect(msgs, model),
|
MessageV2.toModelMessagesEffect(msgs, model),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Context, Effect, Layer } from "effect"
|
import { Context, Effect, Layer } from "effect"
|
||||||
|
|
||||||
import { Instance } from "../project/instance"
|
import { InstanceState } from "@/effect/instance-state"
|
||||||
|
|
||||||
import PROMPT_ANTHROPIC from "./prompt/anthropic.txt"
|
import PROMPT_ANTHROPIC from "./prompt/anthropic.txt"
|
||||||
import PROMPT_DEFAULT from "./prompt/default.txt"
|
import PROMPT_DEFAULT from "./prompt/default.txt"
|
||||||
@@ -33,7 +33,7 @@ export function provider(model: Provider.Model) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Interface {
|
export interface Interface {
|
||||||
readonly environment: (model: Provider.Model) => string[]
|
readonly environment: (model: Provider.Model) => Effect.Effect<string[]>
|
||||||
readonly skills: (agent: Agent.Info) => Effect.Effect<string | undefined>
|
readonly skills: (agent: Agent.Info) => Effect.Effect<string | undefined>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,22 +45,22 @@ export const layer = Layer.effect(
|
|||||||
const skill = yield* Skill.Service
|
const skill = yield* Skill.Service
|
||||||
|
|
||||||
return Service.of({
|
return Service.of({
|
||||||
environment(model) {
|
environment: Effect.fn("SystemPrompt.environment")(function* (model: Provider.Model) {
|
||||||
const project = Instance.project
|
const ctx = yield* InstanceState.context
|
||||||
return [
|
return [
|
||||||
[
|
[
|
||||||
`You are powered by the model named ${model.api.id}. The exact model ID is ${model.providerID}/${model.api.id}`,
|
`You are powered by the model named ${model.api.id}. The exact model ID is ${model.providerID}/${model.api.id}`,
|
||||||
`Here is some useful information about the environment you are running in:`,
|
`Here is some useful information about the environment you are running in:`,
|
||||||
`<env>`,
|
`<env>`,
|
||||||
` Working directory: ${Instance.directory}`,
|
` Working directory: ${ctx.directory}`,
|
||||||
` Workspace root folder: ${Instance.worktree}`,
|
` Workspace root folder: ${ctx.worktree}`,
|
||||||
` Is directory a git repo: ${project.vcs === "git" ? "yes" : "no"}`,
|
` Is directory a git repo: ${ctx.project.vcs === "git" ? "yes" : "no"}`,
|
||||||
` Platform: ${process.platform}`,
|
` Platform: ${process.platform}`,
|
||||||
` Today's date: ${new Date().toDateString()}`,
|
` Today's date: ${new Date().toDateString()}`,
|
||||||
`</env>`,
|
`</env>`,
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
]
|
]
|
||||||
},
|
}),
|
||||||
|
|
||||||
skills: Effect.fn("SystemPrompt.skills")(function* (agent: Agent.Info) {
|
skills: Effect.fn("SystemPrompt.skills")(function* (agent: Agent.Info) {
|
||||||
if (Permission.disabled(["skill"], agent.permission).has("skill")) return
|
if (Permission.disabled(["skill"], agent.permission).has("skill")) return
|
||||||
|
|||||||
Reference in New Issue
Block a user