gizatechxyz / scarb-agent

All you need to build provable web3 Agents!
https://orion-giza.gitbook.io/scarb-agent
Apache License 2.0
4 stars 0 forks source link

Handle pre/postprocess #18

Closed raphaelDkhn closed 2 months ago

raphaelDkhn commented 2 months ago

An agent can have pre- or post-processing. This is the logic called before or after the execution of a Cairo program. This is useful for not transmitting or returning a large and complex data structure in the Cairo program, but only the data that the Cairo program needs to perform the verifiable computation.

Pre/post-processing was added by Gonzalo on OrionRunner. However, when developing an agent, we should avoid using OrionRunner as it's adding overhead in the DX. This PR introduces the pre/post-processing mechanism in cairo-hints.

If you pass --preprocess or --postprocess flags, scarb hints-run will run the respective endpoints. By default, these endpoints are localhosts, but you can change them with env variables PREPROCESS_URL and POSRPROCESS_URL.

The pre-processing input is a JSON string, which you pass with --args_json.

This way, you can E2E-test your agent directly with scarb hints.