# Is there an alternative to the agents\_first keyword?

**URL:** <https://discourse.julialang.org/t/is-there-an-alternative-to-the-agents-first-keyword/113272>\
**Category:** Modelling & Simulations\
**Created:** [April 20, 2024, 1:13pm UTC](https://discourse.julialang.org/t/is-there-an-alternative-to-the-agents-first-keyword/113272 "2024-04-20T13:13:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefkuypers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefkuypers/32/19185_2.png) [@stefkuypers](https://discourse.julialang.org/u/stefkuypers)\
**Post date:** [April 20, 2024, 1:13pm UTC](https://discourse.julialang.org/t/is-there-an-alternative-to-the-agents-first-keyword/113272/1 "2024-04-20T13:13:48Z")

</div>

I’m upgrading my code to Agents.jl 6.x and I get an error stating that there is an unsupported keyword “agents\_first” for the run! function. I guess that the default is still the same (agents first) but I need the model\_step! function to be called before the agent\_step! function. Is there a new way to accomplish this?

This is the code I’m running:

```julia
function stepper!(model::ABM, step::Integer)
    model.step += 1

    return step >= model.run_steps
end

function run_econo_model!(model::ABM, steps::Integer, actors_first = false; kwargs...)
    abmproperties(model)[:run_steps] = steps

    run!(model, stepper!, agents_first = actors_first; kwargs...)
end
```

This is the complete error I’m getting:  
SuMSy contribution - none: Error During Test at /Users/stef/Programming/Visual Studio/EconoSim.jl/test/models\_test.jl:5  
Got exception outside of a @test  
MethodError: no method matching run!(::StandardABM{Nothing, MonetaryActor, Dict{Int64, MonetaryActor}, Tuple{DataType}, typeof(actor\_step!), typeof(econo\_model\_step!), typeof(Agents.Schedulers.fastest), Dict{Symbol, Any}, Random.TaskLocalRNG}, ::typeof(EconoSim.stepper!); agents\_first::Bool, adata::Vector{typeof(sumsy\_assets)})

Closest candidates are:  
run!(::Any, ::Any, ::Any, ::Any; when, when\_model, mdata, adata, obtainer, agents\_first, showprogress, warn\_deprecation)  
@ Agents ~/.julia/packages/Agents/ONd0c/src/deprecations.jl:118  
run!(::AgentBasedModel, ::Any, ::Int64; warn\_deprecation, kwargs…)  
@ Agents ~/.julia/packages/Agents/ONd0c/src/deprecations.jl:115  
run!(::AgentBasedModel, ::Union{Function, Real}; when, when\_model, mdata, adata, obtainer, showprogress, init, dt) got unsupported keyword argument “agents\_first”  
@ Agents ~/.julia/packages/Agents/ONd0c/src/simulations/collect.jl:100  
…

Stacktrace:  
[1] kwerr(::@NamedTuple{agents\_first::Bool, adata::Vector{typeof(sumsy\_assets)}}, ::Function, ::StandardABM{Nothing, MonetaryActor, Dict{Int64, MonetaryActor}, Tuple{DataType}, typeof(actor\_step!), typeof(econo\_model\_step!), typeof(Agents.Schedulers.fastest), Dict{Symbol, Any}, Random.TaskLocalRNG}, ::Function)  
@ Base ./error.jl:165  
[2] run\_econo\_model!(model::StandardABM{Nothing, MonetaryActor, Dict{Int64, MonetaryActor}, Tuple{DataType}, typeof(actor\_step!), typeof(econo\_model\_step!), typeof(Agents.Schedulers.fastest), Dict{Symbol, Any}, Random.TaskLocalRNG}, steps::Int64, actors\_first::Bool; kwargs::@Kwargs{adata::Vector{typeof(sumsy\_assets)}})  
@ EconoSim ~/Programming/Visual Studio/EconoSim.jl/src/models/econo\_model.jl:88  
[3] macro expansion  
@ ~/Programming/Visual Studio/EconoSim.jl/test/models\_test.jl:9 [inlined]  
[4] macro expansion  
@ ~/Library/Julia/Julia-1.10.app/Contents/Resources/julia/share/julia/stdlib/v1.10/Test/src/Test.jl:1577 [inlined]  
[5] top-level scope  
@ ~/Programming/Visual Studio/EconoSim.jl/test/models\_test.jl:6  
[6] eval  
@ ./boot.jl:385 [inlined]  
[7] include\_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)  
@ Base ./loading.jl:2076  
[8] include\_string(m::Module, txt::String, fname::String)  
@ Base ./loading.jl:2086  
[9] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})  
@ Base ./essentials.jl:892  
[10] invokelatest(::Any, ::Any, ::Vararg{Any})  
@ Base ./essentials.jl:889  
[11] inlineeval(m::Module, code::String, code\_line::Int64, code\_column::Int64, file::String; softscope::Bool)  
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/VSCodeServer/src/eval.jl:263  
[12] (::VSCodeServer.var"#69#74"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()  
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/VSCodeServer/src/eval.jl:181  
[13] withpath(f::VSCodeServer.var"#69#74"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)  
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/VSCodeServer/src/repl.jl:274  
[14] (::VSCodeServer.var"#68#73"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()  
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/VSCodeServer/src/eval.jl:179  
[15] hideprompt(f::VSCodeServer.var"#68#73"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})  
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/VSCodeServer/src/repl.jl:38  
[16] (::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()  
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/VSCodeServer/src/eval.jl:150  
[17] with\_logstate(f::Function, logstate::Any)  
@ Base.CoreLogging ./logging.jl:515  
[18] with\_logger  
@ ./logging.jl:627 [inlined]  
[19] (::VSCodeServer.var"#66#71"{VSCodeServer.ReplRunCodeRequestParams})()  
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/VSCodeServer/src/eval.jl:255  
[20] #invokelatest#2  
@ ./essentials.jl:892 [inlined]  
[21] invokelatest(::Any)  
@ Base ./essentials.jl:889  
[22] (::VSCodeServer.var"#64#65")()  
@ VSCodeServer ~/.vscode/extensions/julialang.language-julia-1.76.2/scripts/packages/VSCodeServer/src/eval.jl:34  
Test Summary: | Error Total Time  
SuMSy contribution - none | 1 1 1.0s  
ERROR: Some tests did not pass: 0 passed, 0 failed, 1 errored, 0 broken.

Thanks in advance,  
Stef

---

<div class="post-metadata">

**Author:** ![Tortar](https://avatars.discourse-cdn.com/v4/letter/t/6bbea6/32.png) [@Tortar](https://discourse.julialang.org/u/Tortar)\
**Post date:** [April 20, 2024, 1:25pm UTC](https://discourse.julialang.org/t/is-there-an-alternative-to-the-agents-first-keyword/113272/2 "2024-04-20T13:25:21Z")

</div>

In v6 `agents_first` should be specified at model creation:

`StandardABM(...; agents_first = true)`

this seems a bit too restrictive though and it can be easily improved (just make it possible to change `agents_first` in the model), please open an issue on Github to track it if this is creating problems to you

---

<div class="post-metadata">

**Author:** ![stefkuypers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefkuypers/32/19185_2.png) [@stefkuypers](https://discourse.julialang.org/u/stefkuypers)\
**Post date:** [April 21, 2024, 8:31am UTC](https://discourse.julialang.org/t/is-there-an-alternative-to-the-agents-first-keyword/113272/3 "2024-04-21T08:31:35Z")

</div>

Thanks! In my case I can work with that. I guess the developers thought that there would be very few cases where you’d need to change the parameter from one run to another. There probably are some though.
