Skip to content

Bug: input generator instance is reset by runner, losing state #2292

@mattbit

Description

@mattbit

I have written a custom input generator, similar to a PersonaSimulator. I used the WithGeneratorMixin to provide the LLM generator instance.

The issue is that this generator is reset to default value at runtime:

my_simulator = MySimulator(generator=Generator(model="my-model"))

At runtime in the scenario, the simulator generator is reset to the default value from get_default_generator.

This happens because the instance is serialized and then deserialized at runtime, but the generator field is excluded from the serialized object. So it's lost.

Some questions:

  • why is the input generator serialized and deserialized (can't we instead keep the same instance?)
  • instead of serializing, shouldn't we use model_copy()
  • do we really need to exclude the generator field from the serialized version? It should be serializable

In my case, the only solution was to set the default generator so that it would be set to the right value every time, but this is not practicel.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions