Former Labour leader Ed Miliband could be offered a position in his successor Jeremy Corbyn's shadow cabinet after completing his break from frontline politics, shadow chancellor John McDonnell has said.

Giving his analysis of Labour's defeat at the May general election, Mr McDonnell suggested it could have won if Mr Miliband had positioned it as an "anti-austerity" party.

But he praised him as an "extremely capable, bright, intelligent and sincere politician" and left no doubt that he would like to see him on the Corbyn front bench.

Mr Corbyn was generous in his appreciation of Mr Miliband in his keynote speech to Labour's annual conference in Brighton, thanking his predecessor for the leadership he gave the party and for his "courage and dignity".

And he appeared to leave open the possibility of a future frontline position for the former leader by thanking him also for "the contribution I know he will be making in the future, especially on the vital issues of the environment and climate change".

Speaking at a meeting hosted by The Guardian on the fringe of the Brighton gathering, Mr McDonnell was also full of praise for Mr Miliband, who he suggested should have stayed on as leader for some time after taking Labour to defeat in the May general election.

"After Ed lost, I was hoping he would stay on at least for a period," said the shadow chancellor, to applause from delegates. "I had a lot of time for Ed Miliband. I thought he was an extremely capable, bright, intelligent and sincere politician.

"I am hoping, when he has had a year out - and that is what he is thinking of - he will come back to serve in the Corbyn administration, because I think he is extremely talented and the work he did in the environmental field was second to none."

Asked why he felt Mr Miliband had failed to lead Labour to victory, Mr McDonnell said: "I think if we had come out as an anti-austerity party before the election, we would have stood a better chance of winning. We would have had a very clear message.

"If we had developed over the previous years our economic credibility, we would have won the election.

"Having learnt that lesson, that is what we are doing now."

Mr McDonnell said that Mr Miliband was "a really well-intentioned socialist", but added: "The party at that time was in a state of flux and wasn't sure whether it was anti-austerity or austerity-lite and people were confused. That allowed in Scotland the Scottish National Party to take seats off us and in parts of the country it allowed Ukip to take votes off us."

He added: "I think it wasn't clear enough in its ambitions of what it intended to do. If we had delivered an economic analysis with this clarity, demonstrating we could manage the economy without austerity and grow a prosperous economy, I think we would have at least been the largest party, if not a majority party."