7575 RefineSpecApiOutput ,
7676 SubmitAnswersRequest ,
7777)
78- from kiln_server .utils .agent_checks .policy import ALLOW_AGENT
78+ from kiln_server .utils .agent_checks .policy import agent_policy_require_approval
7979from pydantic import BaseModel , Field
8080
8181logger = logging .getLogger (__name__ )
@@ -115,7 +115,11 @@ class CreateSpecWithCopilotRequest(BaseModel):
115115
116116
117117def connect_copilot_api (app : FastAPI ):
118- @app .post ("/api/copilot/clarify_spec" , tags = ["Copilot" ], openapi_extra = ALLOW_AGENT )
118+ @app .post (
119+ "/api/copilot/clarify_spec" ,
120+ tags = ["Copilot" ],
121+ openapi_extra = agent_policy_require_approval ("Run Copilot spec clarification?" ),
122+ )
119123 async def clarify_spec (input : ClarifySpecApiInput ) -> ClarifySpecApiOutput :
120124 api_key = get_copilot_api_key ()
121125 client = get_authenticated_client (api_key )
@@ -141,7 +145,11 @@ async def clarify_spec(input: ClarifySpecApiInput) -> ClarifySpecApiOutput:
141145 detail = "Unknown error." ,
142146 )
143147
144- @app .post ("/api/copilot/refine_spec" , tags = ["Copilot" ], openapi_extra = ALLOW_AGENT )
148+ @app .post (
149+ "/api/copilot/refine_spec" ,
150+ tags = ["Copilot" ],
151+ openapi_extra = agent_policy_require_approval ("Run Copilot spec refinement?" ),
152+ )
145153 async def refine_spec (input : RefineSpecApiInput ) -> RefineSpecApiOutput :
146154 api_key = get_copilot_api_key ()
147155 client = get_authenticated_client (api_key )
@@ -168,7 +176,9 @@ async def refine_spec(input: RefineSpecApiInput) -> RefineSpecApiOutput:
168176 )
169177
170178 @app .post (
171- "/api/copilot/generate_batch" , tags = ["Copilot" ], openapi_extra = ALLOW_AGENT
179+ "/api/copilot/generate_batch" ,
180+ tags = ["Copilot" ],
181+ openapi_extra = agent_policy_require_approval ("Run Copilot batch generation?" ),
172182 )
173183 async def generate_batch (input : GenerateBatchApiInput ) -> GenerateBatchApiOutput :
174184 api_key = get_copilot_api_key ()
@@ -195,7 +205,11 @@ async def generate_batch(input: GenerateBatchApiInput) -> GenerateBatchApiOutput
195205 detail = "Unknown error." ,
196206 )
197207
198- @app .post ("/api/copilot/question_spec" , tags = ["Copilot" ], openapi_extra = ALLOW_AGENT )
208+ @app .post (
209+ "/api/copilot/question_spec" ,
210+ tags = ["Copilot" ],
211+ openapi_extra = agent_policy_require_approval ("Run Copilot spec questioner?" ),
212+ )
199213 async def question_spec (
200214 input : SpecQuestionerApiInput ,
201215 ) -> QuestionSet :
@@ -226,7 +240,9 @@ async def question_spec(
226240 @app .post (
227241 "/api/copilot/refine_spec_with_question_answers" ,
228242 tags = ["Copilot" ],
229- openapi_extra = ALLOW_AGENT ,
243+ openapi_extra = agent_policy_require_approval (
244+ "Run Copilot spec refinement with question answers?"
245+ ),
230246 )
231247 async def submit_question_answers (
232248 request : SubmitAnswersRequest ,
@@ -256,7 +272,7 @@ async def submit_question_answers(
256272 @app .post (
257273 "/api/projects/{project_id}/tasks/{task_id}/spec_with_copilot" ,
258274 tags = ["Copilot" ],
259- openapi_extra = ALLOW_AGENT ,
275+ openapi_extra = agent_policy_require_approval ( "Create spec with Copilot?" ) ,
260276 )
261277 async def create_spec_with_copilot (
262278 project_id : Annotated [
0 commit comments