Skip to content

Conversation

@WonderPG
Copy link
Collaborator

@WonderPG WonderPG commented Sep 12, 2025

Contributes to #489

How it works

The backend is adjusted to accept descriptions of full simulation campaigns or incremental changes. The frontend passes the current simulation config in the request body which the backend recovers. The final simulation json is split into json patches that are returned in the tool output. The frontend is responsible for applying them to their state.
The frontend shows a button next to relevant tools (smc simulation config in this case) which opens a sidebar. When the tool call is done, the JSON displayed updates. You can also modify it directly in the frontend, the changes will be seen by the backend on the next request

Disclaimer

  • I did not implement any logic to handle conflicts (frontend + backend changing the state simultaneously)
  • I tried to implement a diffing mechanism but I gave up. The changes are all accepted by default. To see the diff mechanism in action, please checkout a786bd0 (no guarantee)
  • The simulation state is thread bound (not stored in the store). I made this decision for simplicity. Each thread starts with a default simulation config, which can be updated through the tool. Changing thread sets your simulation config to the latest state it had in this conversation.
  • I didn't add a global button to open the state. I estimated that the state is somewhat bound to the tool call, so you need to call the obione-generatesimulationsconfig to see the button appear and to be able to open the sidebar. It currently shows only the simulation config json, not the whole state.
  • Because it is thread bound, when switching thread the simulation config defaults to a basic simulation, and all of the patches of the tools are applied sequentially. Therefore there are two issues
    • The changes made manually to the JSON in the frontend are not re-applied on reload
    • If you made a manual change then called the tool to make yet another modification that changes what you manually updated, it is possible that on reload the json won't be valid anymore (since your manual changes will not be applied, but the tool changes will)

The frontend is far from perfect, but tracking correctly this json and its diffs (tool + frontend) is too much of a task for this ticket imo. Feel free to disagree and make changes !

Comment on lines -128 to -130
from neuroagent.tools.obione_generatesimulationsconfig import (
GenerateSimulationsConfigTool,
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had an annoying cyclic dependency that I could resolve only by not importing this tools in the __init__. If you have a better idea let me know. The dependency is

conftest -> neuroagent.app.dependencies -> neuroagent.agent_routine -> neuroagent.new_types -> neuroagent.tools.autogenerated_types.obione -> neuroagent.tools.__init__ -> neuroagent.tools.obione_generatesimulationsconfig -> new_types

@WonderPG WonderPG marked this pull request as ready for review September 12, 2025 13:37
Comment on lines +65 to +95
>({
smc_simulation_config: {
type: "SimulationsForm",
timestamps: {},
stimuli: {},
recordings: {},
neuron_sets: {},
synaptic_manipulations: {},
initialize: {
type: "SimulationsForm.Initialize",
circuit: {
type: "CircuitFromID",
id_str: "",
},
node_set: {
block_dict_name: "",
block_name: "",
type: "NeuronSetReference",
},
simulation_length: 1000,
extracellular_calcium_concentration: 1.1,
v_init: -80,
random_seed: 1,
},
info: {
type: "Info",
campaign_name: "name",
campaign_description: "description",
},
},
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would store this default at the top of the file and just link here. Of course highly subjective.

Comment on lines +106 to +108
if base_simulation_form is None:
raise ValueError(
f"To edit a Small Microcircuit Simulation, first navigate to {self.metadata.entity_frontend_url + '/simulate?&s=new&t=small-microcircuit'}, pick a circuit, click 'New Simulation' and call the tool again."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed privately. Another option is to set base_simulation_form={}. Your call

description: ClassVar[
str
] = """This tool generates JSON configurations for simulations based on natural language descriptions. It takes a user's request for a configuration (including modifications to existing configs) and uses an LLM with structured output to produce the corresponding JSON.
] = """This tool generates JSON configurations for simulations based on natural language descriptions. It accepts both complete configuration specifications and modification requests for existing configurations, using an LLM with structured output to produce the corresponding JSON.
Copy link
Collaborator

@jankrepl jankrepl Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance we could advise the LLM not to "copy paste" the raw json patch from the tool output to the ai-message.

See what it did

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First time I see it. Sure I will prompt it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants