| 333 | } |
| 334 | |
| 335 | pub fn run_agent<'gc>( |
| 336 | state: &mut State<'gc>, |
| 337 | agent: Gc<'gc, Agent<'gc>>, |
| 338 | args: Vec<Value<'gc>>, |
| 339 | ) -> Value<'gc> { |
| 340 | if Handle::try_current().is_ok() { |
| 341 | // We're in an async context, use await |
| 342 | Handle::current().block_on(async { _run_agent(state, agent, args).await }) |
| 343 | } else { |
| 344 | // We're in a sync context, create a new runtime |
| 345 | let runtime = tokio::runtime::Runtime::new().unwrap(); |
| 346 | runtime.block_on(async { _run_agent(state, agent, args).await }) |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | impl From<PrimitiveType> for JSONSchemaType { |
| 351 | fn from(ty: PrimitiveType) -> Self { |