Skip to content

Agent type (task stream) argument is not validated #1049

Description

@mintybasil

Presently there is no validation of the value passed to the agent binary with -t/--task_stream.

This value is passed directly to the database, which can result in strange and unexpected behaviour. Notably, the agent will start up, show no errors and receive no work.

Steps to Reproduce

  1. Start the boundless stack per the quickstart guide (just bento up)
  2. Run another agent with -t notatype
docker run \
  --name "test_agent" \
  --network "bento_default"
  -e DATABASE_URL="postgresql://worker:password@postgres:5432/taskdb" \
  -e REDIS_URL="redis://redis:6379" \
  -e S3_URL="http://minio:9000" \
  -e S3_BUCKET="workflow" \
  -e S3_ACCESS_KEY="admin" \
  -e S3_SECRET_KEY="password" \
  -e RUST_LOG="info" \
  -e RUST_BACKTRACE="1" \
  --entrypoint /app/agent \
  risczero/risc0-bento-agent:2.3.0@sha256:5b029fb8074b3273b45e6e8fb4d6dbd86000a216688d8f1429eb893686cc1ff8 \
  -t notatype 

Which will result in this:

2025-08-29T16:23:14.370328Z  INFO sqlx::postgres::notice: relation "_sqlx_migrations" already exists, skipping
2025-08-29T16:23:14.371437Z  INFO agent: Successful agent startup! Worker type: notatype

Relevant Code

Agent is instantiated with args:

let agent = Agent::new(args)
.await
.context("Failed to initialize Agent")?;
sqlx::migrate!("../taskdb/migrations")
.run(&agent.db_pool)
.await
.context("Failed to run migrations")?;
tracing::info!("Successful agent startup! Worker type: {task_stream}");
// Poll until agent is signaled to exit:
agent.poll_work().await.context("Exiting agent polling")

task_stream is passed directly to DB:

let task = taskdb::request_work(&self.db_pool, &self.args.task_stream)

Proposed Fix

Implement an enum for the different agent types and let clap parse the input.

use clap::{Parser, ValueEnum};

#[derive(Debug, Clone, ValueEnum)]
#[clap(rename_all = "kebab-case")]
enum TaskStreamType {
    Prove,
    Snark,
    Aux,
    Exec,
}

#[derive(Parser, Debug, Clone)]
#[command(author, version, about, long_about = None)]
pub struct Args {
    ...
    #[arg(value_parser = clap::value_parser!(TaskStreamType))]
    task_stream: TaskStreamType,
    ...
}

If someone can validate this fix I would be happy to open a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginfra

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions