# Id error on creating an agent

**URL:** https://discourse.julialang.org/t/id-error-on-creating-an-agent/113270
**Category:** Modelling & Simulations
**Tags:** agentsjl
**Created:** [April 20, 2024, 11:54am UTC](https://discourse.julialang.org/t/id-error-on-creating-an-agent/113270 "2024-04-20T11:54:21Z")
**Posts on this page:** 2
**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, 11:54am UTC](https://discourse.julialang.org/t/id-error-on-creating-an-agent/113270/1 "2024-04-20T11:54:21Z")

</div>

I am in the process of updating my code for the Agents.jl 6.x package and I’m running into some trouble.

I have the following Agents structures:

```julia
@agent struct Actor(NoSpaceAgent)
    types::Set{Symbol} = Set{Symbol}()
    behaviors::Vector{Function} = Vector{Function}()
    properties::D where {D <: Dict{Symbol, <:Any}} = Dict{Symbol, Any}()
end

@agent struct MonetaryActor(Actor)
    balance::AbstractBalance = Balance()
end
```

If I execute:

```julia
MonetaryActor()
```

I get the following error:  
ERROR: UndefKeywordError: keyword argument `id` not assigned  
Stacktrace:  
[1] MonetaryActor()  
@ EconoSim ~/.julia/packages/Agents/ONd0c/src/core/agents.jl:216  
[2] top-level scope  
@ REPL[1]:1

It seems that there is a problem with assigning an id. What am I missing?

---

<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, 12:24pm UTC](https://discourse.julialang.org/t/id-error-on-creating-an-agent/113270/2 "2024-04-20T12:24:31Z")

</div>

This is due to the fact that `id` can’t be decided automatically if you don’t pass the `model` instance.

One of these two should work instead:

```julia
julia> model = StandardABM(MonetaryActor);

julia> MonetaryActor(id = 1)
MonetaryActor(1, Set{Symbol}(), Function[], Dict{Symbol, Any}(), Balance())

julia> MonetaryActor(model)
MonetaryActor(1, Set{Symbol}(), Function[], Dict{Symbol, Any}(), Balance())

```
